Selecting pixels by specification in Photoshop

I use Photoshop for carpet designing. My typical artwork is 1800 × 2400 pixels with 8 or 10 colors. Each pixel’s position and color is important.

The weaving macine which outputs the carpet can’t make 1 pix high horizontal single color lines in good quality if the line has length 10 pix or more. A single color pattern can well be 10 pix (or more) wide if it is higher than 1 pix.

See my image sample. I have marked some problematic lines:

Photoshop selection

Until this I have walked through the image manually and replaced the problematic lines one by one. That’s very time consuming job and easily some errors stay unnoticed.

I need a fast method – maybe a script or Photoshop plugin or separate program – that finds all those 1×10 (or more) single color lines and replaces them with another pattern of the same color. Even automatic finding would be a delight. If I could define also other patterns to be found and replaced, the software add-on would be luxorius.

Can anyone help me?


I do not have a complete solution, but I do have some ideas. Getting each of the colours into their own channels should make things easier to interrogate.

You can do this by selecting a pixel or two of a colour (and only that colour), then choose SelectSimilar.

Photoshop select similar

With all the pixels of a single colour selected, you can now save the selection, which will create a new channel.

Here’s where things get a bit more difficult and hand-wavy. Through some processing, we should hopefully be able to keep the lines that are 10px wide or longer, but remove all others.

Here’s a test pure black and white selection with some varying line lengths. The top two lines are 12px and 10px wide respectively, and the ones underneath are shorter. We’re trying to keep the 10 and 12px lines, but remove the others.

enter image description here

Duplicating the selection a few times, offsetting it, and using varying opacity for the layers gets us part of the way there. I used 5px offsets and 50% and 33% opacity, plus levels to take the grey pixels back to white (keeping the ones we want).

enter image description here

Another pass using the same method, but this time with a 3px offset.

enter image description here

And a final pass, doing exactly what we did in the first pass. I think this should give the required result, and also be able to be automated by recording an action.

enter image description here

With a good selection, filling those parts of the image with a pattern should be pretty easy. A pattern layer using the newly created mask would work for that.

Here’s a GIF of the steps used. I think it should work with any initial artwork.

GIF process

Now I think about it, I think this entire structure could be set up using smart objects and smart filters, so you’d just have to replace the contents of the smart object to process it (assuming the source artwork is the same dimensions).

Source : Link , Question Author : raha bolandian , Answer Author : Marc Edwards

Leave a Comment