'Image processing: Detecting "black patches" in a "white area" (with Java)
My problem is to detect the black "holes" in BMP images like the following:
https://www.hmmueller.de/Diagrams_x560/image0001.bmp
Here is another example:
https://www.hmmueller.de/Diagrams_x560/image0002.bmp
To find the black "blotches", I first simple create a "greyscale" image by adding R+G+B. In the hope of having a bimodal distribution for this values, I used a Java algorithm for Otsu's method (https://en.wikipedia.org/wiki/Otsu%27s_method), but the resulting threshold of 59 is apparently way off - here is the actual distribution, cut off somewhere below the maximum R+G+B value of 255+255+255, which has an even higher frequency count:
https://www.hmmueller.de/Diagrams_x560/DistBMP.JPG
Practically, I'd put the threshold at 500 - but is there a better way to find a threshold for the "obviously dark blotches"?
(From there on, I'd use a flood fill that finds all contiguous areas below threshold; and returns bounding rectangles for the blotches, which is good enough for my further needs).
Thank you! H.M.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
