Image Segmentation, Threshoding

김민혁·2025년 1월 30일
0

컴퓨터 비전

목록 보기
12/19

Minhyeok의 Notion - 노션에서 옮기는 중

Thresholding

  • Global thresholding
    • Basic: 이미지를 두 그룹으로 나눈 후 평균값 계산, 반복 ⇒ threshold

    • Otsu’s method
      1. normalized histogram 계산
      2. 모든 threshold에 대해 분산 계산
      3. 가장 큰 분산을 가진 threshold 선택

      // thresh: 100, 임계값 이상이면 될 값: 255
      threshold(image, dst, 100, 255, THRESH_BINARY);
  • Local(adaptive) thresholding
    • 각 픽셀에 다른 thresholding

    • 인접 픽셀의 intensity 분포 기반 각 point에 threshold 선택

      adaptiveThreshold(image, dst, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 7, 10)
      // 두 값의 중간 값을 추출 => 1
      inRange(image, Scalar(0,133, 77), Scalar(255, 173, 127)

GrabCut

  • Operation
    1. rectangle 설정
    2. rectangle을 기준으로 각 픽셀을 foreground/background 로 labeling
    3. GMM(Gaussian Mixture Model) 사용
    4. 각 픽셀들은 GMM에 의해 확률값으로 labeling
    5. 픽셀 분포 → 그래프 생성:
      1. foreground pixel → source node
      2. background pixel → sink node
    6. source/sink node 에 연결된 edge 에 확률값 기반 weight 형성
    7. pixel들을 연결하는 edge 에 색상 변화, 유사성 기반 weight 형성
      1. 유사도 높을 수록 높은 weight
    8. mincut: 엣지 weight의 합이 최소인 곳을 분할
    9. background/foreground (sink/source) 으로 나뉨
    10. 수렴할 때까지 반복
  • GMM
    • Bayes rule
// 알고리즘 10번 반복
grabCut(image, result, rectangle, bgdModel, fgdModel, 10, GC_INIT_WITH_RECT);
profile
해야한다면, 다 하게 되더라.

0개의 댓글