Computer Vision

OpenCV: cvThreshold() 함수 연습

maetel 2010. 9. 26. 19:30
OpenCV 함수 cvTreshold or cv::threshold

source code link: https://code.ros.org/trac/opencv/browser/tags/2.1/opencv/src/cv/cvthresh.cpp
file: /opencv/src/cv/cvthresh.cpp


Learning OpenCV: Chapter 5 Image Processing: Threshold (135p)


cf. Otsu method




원본 영상

입력 영상



threshold=100, max_val=100, CV_THRESH_BINARY

threshold=100, max_val=200, CV_THRESH_BINARY

threshold=200, max_val=200, CV_THRESH_BINARY



threshold=50, CV_THRESH_TRUNC

threshold=50, CV_THRESH_TRUNC

threshold=150, CV_THRESH_TRUNC



threshold=50, CV_THRESH_TOZERO

threshold=100, CV_THRESH_TOZERO

threshold=200, CV_THRESH_TOZERO



threshold=100, max_val=200, CV_THRESH_BINARY

threshold=100, max_val=200, CV_THRESH_BINARY & CV_THRESH_OTSU

threshold=100, max_val=200, CV_THRESH_OTSU


코드에서 CV_THRESH_OTSU는 CV_THRESH_BINARY | CV_THRESH_OTSU 와 같은 효과.
CV_THRESH_OTSU는 함수의 인자 "threshold"의 초기값과 무관하게 입력 영상에 대해 내부적으로 threshold 값을 구하고 이에 따라 선택된 픽셀들에 max_value 값을 준다.