Is it possible in OpenCV to plot local curvature as a heat-map representing an object's “pointiness”?

前端 未结 2 1293
滥情空心
滥情空心 2021-02-09 18:03

Given a thresholded image of blobs that you can detect and draw contours around, is it possible when drawing the contour to represent the local curvature as a heat-map?

<
2条回答
  •  逝去的感伤
    2021-02-09 18:42

    The point is that " if you approximate the contour to continues lines you can see that the pointiness is the point where maximum angle deviation for consecutive line occurs", based on this you can develop your algorithm.

    You need to do

    1. Find contour.

    2. Find approxPolyDP() for the contour.

    3. Calculate angle for each consecutive line and store the point where the maximum deviation occur.

    You can calculate the angle of a line using the equation

       double Angle = atan2(P2.y - P1.y, P2.x - P1.x) * 180.0 / CV_PI; 
    

提交回复
热议问题