Search code examples
pythonopencvimage-segmentationfalse-positiveexpectation-maximization

Eliminating False Positives detected by OpenCV EM


I am developing an algorithm in Python, which is supposed to identify the area on a leaf that contains spots to report the severity of a disease. During my research, I found out about LeafSnap and got inspired by it. So, I tried to follow the paper to segment the leaf on the image using OpenCV Expectation Maximization, which is trained using S and V form HSV color space; however, it still returns some false positives due to reflection or shadow.

First Sample

Second Sample

Could someone try to give me any hint to get some better results? I didn't have applied any techniques of preprocessing!



Solution

  • I don't think Leafsnap is intended to be used in direct sunlight. It creates very strong shadows totally messing up up their S+V method.

    In the paper the authors explain that they drop the hue because it "dilutes" the object when the white paper sheet reflects some of green color. However, in your case, because the photos appear to be taken under clear sky, the paper has either yellowish (in direct sunlight) or blueish (in shadow) hue clearly distinguishable from the green hue of the leafs. In fact, hue layer is the one that reflects the leaves' shape the best in these two cases. Therefore, you should not ignore the hue for finding the shape of leaves.

    As an idea, you could use separately Saturation + Value, as well as Hue to determine the shape. After that choose the smaller shape out of those two.