Skip to main content
Known Participant
February 17, 2017
Question

How to get rid of stray pixels?

  • February 17, 2017
  • 2 replies
  • 12618 views

So I'm working on this huge scan of a map, about 15.000 x 15.000 pixels. The background is cleared, so most of the file is transparent pixels as in the attached (very small) sample, and inbetween the lines and text of the map.

Problem is, I got countless stray pixels of all colors left (not on the sample image, at least not visible ones). While I can make them visible easily enough with Curves or other means, they are just way too many to delete manually with such a huge file.

I would imagine there is a way to select only objects in an image of a certain size, say, nothing larger than 1x1, 2x2, 3x3, 5x5 pixels, is there? With an option like that, I could just select all of the tiny stuff and delete it with one stroke of a key without affecting the larger structures at all. I've been trying different tools to achieve that but haven't found a way yet. Does something like that exist?

This topic has been closed for replies.

2 replies

c.pfaffenbichler
Community Expert
Community Expert
February 17, 2017

Can you provide an affected segment of the (layered) image for testing?

RauPPAuthor
Known Participant
February 17, 2017

I tried it on the Layer Mask but didn't get it to work (maybe I just applied it wrong, though). If you apply Dust & Scratches to the map layer itself it does not work due to the stray pixels being surrounded by transparent pixels. When I merge the map layer with a monochrome (i.e., white) background layer, Dust & Scratches actually works pretty well in getting rid of the stray pixels, however it affects the rest of the elements too.

Thanks a lot for your advice, your method is similar to the one I've been using up to now! Visibility is not the main issue however; it's more that there are just so many of the stray pixels that it takes forever to remove them manually.

Link to a sample PSD file, layered (2.2 MB):

https://www.file-upload.net/download-12318677/StrayPixels01.psd.html

c.pfaffenbichler
Community Expert
Community Expert
February 24, 2017

Righty. This is again similar to the technique I've been using: I made an adjustment layer with maximum contrast and minimum brightness, that made all stray pixels visible. Then I just removed them with the eraser tool.

With a map that is hundreds of times this size it is still a very time consuming matter, it took about 8 hours total. As nothing of importance in the file except for stray pixels was of this size, a simple command to delete every lump of pixels below a certain threshold would've saved a lot of time. I'm very surprised Photoshop doesn't contain a function like this; I'd imagine anyone scanning drawings and the like who needs to clean up backgrounds running into this problem from time to time, even if their files are probably not as huge as mine.


a simple command to delete every lump of pixels below a certain threshold would've saved a lot of time.

But that’s pretty much what Dust & Scratches does.

If it unduly affects (corners of) regions that are not intended to be affected one can try to address this with masking/selecting.

c.pfaffenbichler
Community Expert
Community Expert
February 17, 2017
I would imagine there is a way to select only objects in an image of a certain size, say, nothing larger than 1x1, 2x2, 3x3, 5x5 pixels, is there?

Have you tried the Filter Dust & Scratches on the Layer Mask?

I would recommend something else first, though.

Layer > Layer Mask > From Transparency (if you actually deleted instead of using a Layer Mask)

Layer > Layer Style > Stroke (Outer) to make the stray pixels more noticable

then use the Burn Tool set to Shadows to brush out the stray pixels at View > 100%

remove the Stroke