1

enter image description here

Basically, if you look at the image I want to fill the white noise if it's surrounded by black pixels. Maybe not a single white pixel but I definitely would like to fill the bigger patches. I was thinking maybe I can use javascript logic and scan the image and find white patches within certain sizes, then I can check if they are sounded by black or not. Is there an easy way to do this?

The reason I am asking is this is a tiny zoomed crop of an image I am currently trying to edit. I have a lot of these images and I need to find a way to do this automatically or semi automatically. There is no way I can sit down and do all these myself.

  • 2
    did you by any chance made changes to your question using a different user? if yes please merge them meta.stackexchange.com/help/merging-accounts – Luciano Jul 4 '18 at 8:33
  • It would be much easier to use a graphical editing software to do this than it would be to write something in JS from the ground up, though it is possible using JS – Zach Saucier Jul 5 '18 at 16:23
  • It's a good question, but the problem is how to define what you mean with "surrounded by black pixels". There is a quite large area in the lower left part of your image which is also surrounded by black pixels, but which you want to keep white. How would you logically differentiate between those? (The only reason why the solution of @user287001 works is because he/she deleted one crucial pixel). If you had 8-bit (or more) versions of the images, you might be able to filter them before bitmapping. But when the b/w pixels are "baked" it's (semi) manual work, I'm afraid. – Wolff Jul 5 '18 at 18:35
1

In photoshop or other bitmap graphics software this can be done half-manually assuming the wanted white area is contiguous and somewhere reaches the edge of the image. The image must temporarily be in RGB mode, if it's originally grayscale.

  1. Insert temporarily the image pixel dimensions to have uniform white belt around the image

enter image description here

  1. Use the Paint Bucket. Floodfill the contiguous white area with blue. Have in Paint Bucket options "Antialias" OFF, "Contiguous" ON and proper tolerance set.

enter image description here

  1. Uncheck "Contiguous", floodfill white areas with black

enter image description here

  1. Goto Image > Adjustments > Hue/Saturation and turn Blue to white

enter image description here

  1. Restore the original image size and color mode

This is useless if there's some white areas that should be found more cleverly - for ex. detecting some geometric forms that make them wanted despite they are surrounded by black.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.