regionhalconsymmetry

Halcon - Region Symmetry


Is there a way to detect if a region is symmetric or not on its vertical center axis?

I have this region:

enter image description here

The left side is correct, the right side has this hole.. I need to detect it and would like to do it with symmetry. I was not able to find any symmetry feature in the region features...

how could this be done?

EDIT:

Idea 1:

Find the min. X and max. X of the outer rectangle, and calculate X mean. Then run area_center to find the center of mass and compare the two positions. It should work with examples like the one in the image, and will fail if the deformation does not move the center of mass..


Solution

  • Try:

    * find the center 
    smallest_rectangle1 (Region, Row1, Column1, Row2, Column2)
    
    * mirror the region
    mirror_region (Region, RegionMirror, 'column', Column2+Column1+1)
    
    * merge the original region and the mirror region
    union2 (Region, RegionMirror, RegionEnvelope)
    
    * find the difference between the merged region and the original region
    difference (RegionEnvelope, Region, RegionDifference)
    

    enter image description here

    The blue region is the RegionDifference