difference between CV_RETR_LIST,CV_RETR_TREE,CV_RETR_EXTERNAL?

前端 未结 2 1060
忘掉有多难
忘掉有多难 2021-01-30 17:59

I am using cvFindContour function of opencv and in it there is a parameter RETR_TYPE means retrivel type,hence I am not getting what is the difference between CV_RETR_LIST

相关标签:
2条回答
  • 2021-01-30 18:15

    From imgproc.cpp:

    //! mode of the contour retrieval algorithm
    enum RetrievalModes {
        /** retrieves only the extreme outer contours. It sets `hierarchy[i][2]=hierarchy[i][3]=-1` for
        all the contours. */
        RETR_EXTERNAL  = 0,
        /** retrieves all of the contours without establishing any hierarchical relationships. */
        RETR_LIST      = 1,
        /** retrieves all of the contours and organizes them into a two-level hierarchy. At the top
        level, there are external boundaries of the components. At the second level, there are
        boundaries of the holes. If there is another contour inside a hole of a connected component, it
        is still put at the top level. */
        RETR_CCOMP     = 2,
        /** retrieves all of the contours and reconstructs a full hierarchy of nested contours.*/
        RETR_TREE      = 3,
        RETR_FLOODFILL = 4 //!<
    };
    

    OpenCV 2.4.13

    0 讨论(0)
  • 2021-01-30 18:17

    Look at the documentation for findContours.

    The main difference is in the hierarchy that is returned (giving the relationship between one contour and the next).

    • CV_RETR_EXTERNAL gives "outer" contours, so if you have (say) one contour enclosing another (like concentric circles), only the outermost is given.
    • CV_RETR_LIST gives all the contours and doesn't even bother calculating the hierarchy -- good if you only want the contours and don't care whether one is nested inside another.
    • CV_RETR_CCOMP gives contours and organises them into outer and inner contours. Every contour is either the outline of an object, or the outline of an object inside another object (i.e. hole). The hierarchy is adjusted accordingly. This can be useful if (say) you want to find all holes.
    • CV_RETR_TREE calculates the full hierarchy of the contours. So you can say that object1 is nested 4 levels deep within object2 and object3 is also nested 4 levels deep.
    0 讨论(0)
提交回复
热议问题