0

I have an image that consists of small black dots, and in each dot's vicinity there is some noise that appears as grayish smudge. I'm trying to use some sort of image processing in Python in order to find both the number of (correct) dots and the number of noise smudges, as well as calculate their paramaters (i.e size).

I was thinking of using some sort of contour detection with a certain threshold, since the dots' borders are more distinct, but perhaps there's a better way that I'm not familiar with.

Thank you for your help!

Example Image

wimakog1
  • 31
  • 3
  • Perhaps you can post an example? – fmw42 May 14 '22 at 19:59
  • @fmw42 I've added an example image, thanks (should've done that tbh) – wimakog1 May 14 '22 at 20:27
  • How do we tell the black regions from the black dots that are noise? Are all the black regions, even the point like ones good features for you are are the small ones noise. Can you not just threshold at some gray level to eliminate the gray in the image. – fmw42 May 14 '22 at 20:28
  • @fmw42 Basically the correct dots are the ones which are pure black. It isn't specifically for this image, but for any such image of black dots/shapes on white background – wimakog1 May 14 '22 at 20:32
  • So just threshold at your maximum acceptable black level. – fmw42 May 14 '22 at 21:26
  • @fmw42 But how can I get the number of noise smudges? As well as both dots and smudges sizes? – wimakog1 May 14 '22 at 21:32
  • 1
    Smudge is too spread out to have a size, nor to count. You can count the number of black regions that you like after you threshold. Alternately, threshold a range of gray. That will identify all gray pixels. – fmw42 May 14 '22 at 21:56

1 Answers1

0

Use the Pillow module to analyze each pixel color and compare it against whether its RGB values added together (Assuming its only black and white) are:
Black: 0
Grey: 1-764
White: 765
Hope that helps

Seth Edwards
  • 47
  • 1
  • 7
  • Here is a S.O. answer that show you how to get pixel color value if you choose that path:[Answer](https://stackoverflow.com/a/27960627/13449985) – Seth Edwards May 14 '22 at 20:44