it-source

CV_RETR_LIST,CV_RETR_TREE,CV_RETR_EXTER 간의 차이?

criticalcode 2023. 9. 18. 21:31
반응형

CV_RETR_LIST,CV_RETR_TREE,CV_RETR_EXTER 간의 차이?

저는 opencv의 cvFindContour 기능을 사용하고 있는데 매개변수 RETR_TYPE은 retrivel type을 의미하므로 어떤 차이가 있는지 알 수 없습니다.CV_RETR_LIST,CV_RETR_TREE,CV_RETR_EXTERNAL?

에 대한 설명서를 봅니다.

가장 큰 차이점은.hierarchy(한 등고선과 다음 등고선 간의 관계 제공) 반환됩니다.

  • CV_RETR_EXTERNAL는 "원형" 등고선을 제공하므로, 한 등고선이 다른 등고선(예: 동심원)을 둘러싸는 경우 가장 바깥쪽에 있는 등고선만 제공됩니다.
  • CV_RETR_LIST모든 윤곽을 제공하고 계산조차 하지 않습니다.hierarchy-- 등고선만 원하는 경우에 적합하고 한 등고선이 다른 등고선 안에 중첩되어 있는지 여부는 상관하지 않습니다.
  • CV_RETR_CCOMP등고선을 제공하고 이를 외부 및 내부 등고선으로 구성합니다.모든 윤곽은 물체의 윤곽 또는 다른 물체(즉, 구멍) 내부의 물체의 윤곽입니다.hierarchy그에 따라 조정됩니다.모든 구멍을 찾고 싶을 때 유용할 수 있습니다.
  • CV_RETR_TREE등고선의 전체 계층을 계산합니다.따라서 object1은 object2 내에 4단계 깊이로 중첩되어 있고 object3도 4단계 깊이로 중첩되어 있다고 할 수 있습니다.

부터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

언급URL : https://stackoverflow.com/questions/8830619/difference-between-cv-retr-list-cv-retr-tree-cv-retr-external

반응형