0

I want to match symmetry of object contours. I tried using matchShape(), computeDistance(), Humoments() from opencv 3.0 library. But none of them is close to what I want.

Following are the images on which I am working.

Good Shape-1

Defected

I expect to get highest value of dis-symmetry for image-2(named Defected)

1 Answers1

0

You can do it yourself, by using several simple tools:

  1. Find the centroid
  2. Use PCA (http://docs.opencv.org/master/d1/dee/tutorial_introduction_to_pca.html#gsc.tab=0) to find the main axis
  3. Rotate the shape so that the main axis points up
  4. In each row, count the number of pixels on either side of the center and compare (There should be a single center coordinate, probably using the median value of all rows centers)

You can tune your own thresholds to fit the problem.

Photon
  • 3,182
  • 1
  • 15
  • 16
  • I implemented as you suggested, but I am facing few problem with this solution: 1) I am looking for generalized shape symmetry, i.e. the shape of the object could be circle, square, triangle, fish-like, etc. So considering rotating object along principle axis is not correct. 2) Also for the images I had given in my first post, if the object is broken/defected more in slant than traversing left and right and comparing distance from centre column will give false symmetry error. – Pranay Soni Feb 02 '16 at 06:34
  • 1. The answer was based on examples given in the question. If you put more examples, perhaps there's a generalization. 2. I'm not sure I follow. Unless the defect is the same on both sides, it should work. – Photon Feb 02 '16 at 07:18
  • you may download the images from the link: ![Image Set](http://imgur.com/a/Hi6TL) – Pranay Soni Feb 02 '16 at 10:10
  • 5th and 13th images in the list are defected..you may ignore 12th image in the sequence – Pranay Soni Feb 02 '16 at 10:13
  • Since long I was working on the best solution, finally the method you suggest worked for me. Only modification I made is instead of using threshold to find the error. I extracted left-out areas i.e. areas which are not symmetry, and than checked if the area is on one side of the center of object then those areas (group of pixels) are marked as defects else they are not. – Pranay Soni Feb 20 '16 at 07:14
  • :Thanks for the help – Pranay Soni Feb 20 '16 at 07:14