Hi,
Since the openCv freeman chain code is a bit ambiguous. I am trying to write my own 8 freeman chain code.
I am planning to follow this steps: ->Lets fix the Image size as [W,H]. Now, scale all my vertices data to this Image size i.e. x coordinates need to be multiplied with W and cast it as integers and y coordinates need to be multiplied with H and cast it as integers.
-> Now, I find angle between consecutive vertices v1 and v2 from aTan(y2-y1/x2-x1). ->If this angle is between 337.5 degrees - 22.5 degrees, then the code is 0 (or) if the angle is between 22.5 degrees - 67.5 degrees, then the code is 1. ->So, for a contour,if my freeman chain code is abcdefghab. We try to form a closed chain from this,like:
" babcdefghab "
then we find difference is freeman chain code,like: b - a, a -b , b -c,..........., a - b. Final code: cdefabcd. So, then,I compare final codes of various contours by summing up then differences of 0's, 1's,2's,3's etc. Whichever class has the least sum,I can take that as the classification.
I would be glad,if someonecan tell me,if my approach is fine.