I have some contour image and I want to obtain more simple contour. For example if there is some litle curves such wool of animal or beard of man than I would like to change it woth simple line. For instance on this image from first picture I want to get second. I use cv2 in it.
OpenCV gives you very basic control with the ContourApproximationModes
enum that you pass to the findContours()
function:
CHAIN_APPROX_NONE
stores absolutely all the contour points. That is, any 2 subsequent points(x1,y1)
and(x2,y2)
of the contour will be either horizontal, vertical or diagonal neighbors, that is,max(abs(x1-x2),abs(y2-y1))==1
.
CHAIN_APPROX_SIMPLE
compresses horizontal, vertical, and diagonal segments and leaves only their end points. For example, an up-right rectangular contour is encoded with 4 points.
CHAIN_APPROX_TC89_L1
applies one of the flavors of the Teh-Chin chain approximation algorithm[241]
CHAIN_APPROX_TC89_KCOS
applies one of the flavors of the Teh-Chin chain approximation algorithm[241]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With