Search code examples
pythonopencvimage-processingthreshold

How to use threshold to remove false positives?


I am using OpenCV EM to segment a image on the HSV domain. Therefore, the segmentation detect some false positives [Highlights in Yellow]. Below, you can see the input image.

Input Image

And below, the image segmented with false positives.

False Positives

I try to remove it by using threshold as you can see without success.

Otsu's Example Threshold Example

Any help on how to keep only the Leaf will be appreciated!


Solution

  • The "false positives" you see are compression artefacts caused by JPEG compression.

    https://en.wikipedia.org/wiki/JPEG

    You cannot segment this perfectly in Hue or Saturation channel.

    Ideally process uncompressed images or use brightness information which usually is preserved in higher frequencies than colour.

    Unfortunately you did not provide the actual input image so I cannot help you any further.