Skip to main content
Participating Frequently
July 3, 2018
Question

How to fill these white pixels that are surrounded by these black pixels automatically?

  • July 3, 2018
  • 2 replies
  • 1233 views

Is there a way in photoshop where I can intelligently select the tiny white patches that are surrounded by black pixels to fill those white patches as black? The reason is I have a ton of images I need to process and there is no way I can sit down and do all these myself. Currently, there are 2 issues that I can see, a) the white patch size limit, if it's too big we would end up filling everything. b) there has to be a logic that says you can only fill the patches if they are surrounded by black pixels as well. I can write javascript myself but I don't know where to start...maybe there is an even easier way?

This topic has been closed for replies.

2 replies

Trevor.Dennis
Community Expert
Community Expert
July 4, 2018

Do you have a larger image area we can test with?  My first thought is Dust & Scratches, but that is going to smooth out the pixelated look

You could win that back if you needed to, but without having a much clearer idea of what you are aiming at, it's hard to advise.

Mosaic wins back some of the pixelation — if that's what you want.

And Threshold would kill that AA effect

But like I say, where do you want to go with this?  A much larger area, and a before and after.  You'd have to hand paint the after, but we'd know what you wanted then.

Mylenium
Legend
July 4, 2018

Nope. That would require to write a whole new selection/ fill plug-in with a complex logic that detects white areas within black areas and depending on the nesting levels and other factors this could become infinitely complex. In fact that's probably a good showcase for a deep learning algorithm...

Mylenium

davescm
Community Expert
Community Expert
July 4, 2018

Hi

To add to the reply from Mylenium - how would an algorithm detect the white areas surrounded by black that you want to fill (as you circled) from those that you don't want to fill (to the left of those you circled). Also bear in mind that three of those areas that you circled are not "surrounded" by black - their corners touch white.

Most logic can be written into code but the first step is a set of very clear rules that deal with the ambiguity above.

Dave