I know that scipy.ndimage.label can’t label if the background color is not a solid black.
So I have an image with black background and it’s not a solid black so we can’t assume that all the RGB values are(0,0,0) in all pixels.
How can I prepare the image so I can use ndimage.label??
this is a similar image to test on:
test image http://imageshack.us/a/img4/8661/backgrf.png
Note:
(1) The image was converted fromRGB to PNG gray scale .
(2) The background color varies.
(3) The ndimage.label labels the whole image as one object.
Thanks
This is a simple method for increasing the contrast as far as it can go so that anything “light” becomes white and anything “dark” becomes black. Assuming 8 bit grayscale and adapting the code in @Warren Weckesser’s answer:
Let me know if this works for you.