Area calculation in opencv / javacv?

Please can someone explain how to identify the area that should have red and blue in the following image? I tried using the cvFindContours () method, but it did not give the expected result for me.

Input image

enter image description here

Expected Result

enter image description here I like to know if there are any other methods for determining or calculating an area of ​​this kind of contours. Please be kind to share this simple code example.

+4
source share
1 answer

The floodFill function can also return a region as a return value. So, you can do one raster scan of each pixel: every time you reach an untouched pixel, color it in some color (black) and save the region of this region along with the coordinates of the pixel, continue until the entire image is covered.

In the end, you will have a set of core regions for one pixel in each region.

You need to restore a specific region that you can use floodFill again by painting this region in a specific color.

0
source

All Articles