[OpenCV 3.2] Image Binarization, Thresholding (영상 이진화, 임계값) - 4

OpenCV 라이브러리의 .이진화 함수인 threshold 함수에 대해서 더 알아보려고 한다.


8. threshold 함수에 대해서

 threshold (InputArray src, OutputArray dst, double thresh, double maxval, int type, Stream& stream=Stream::Null())

함수에서 우리는 thresh, maxval, type 세가지의 값을 조정하여 원하는 이진화 이미지를 얻을 수 있다.

1) thresh

 thresh는 이분화의 기준 값이다. Gray Image에서 thresh 값을 기준으로 thresh 초과 값과 이하의 값으로 나누어 이미지를 변환한다.

2) maxval

 maxval은 type가 Binary, Binary Inverted의 경우에 사용되는 변환 값을 나타낸다.

3) type

 type는 5종류로 Binary, Binary Inverted, Threshold Truncated, Threshold to Zero, Threshold to Zero Inverted 로 나누어진다.

가로는 픽셀의 좌표, 세로는 픽셀의 값, 파란색은 thresh 값을 나타낸다.

 - Binary ( type = 0 )

 Binary는 thresh 값을 기준으로 초과 값은 maxval, 이하는 0으로 변환한다.

 - Binary Inverted ( type = 1 )

 Binary Inverted는 thresh 값을 기준으로 초과 값은 0, 이하는 maxval로 변환한다.

 - Truncate ( type = 2 )

 Truncate는 thresh 값을 기준으로 초과 값은 thresh 값으로, 이하는 원래 값 그대로 변환한다.

 - Threshold to Zero ( type = 3 )

 Threshold to Zero는 thresh 값을 기준으로 초과 값은 원래 값 그대로, 이하는 0으로 변환한다.

 - Threshold to Zero Inverted ( type = 4 )

 Threshold to Zero Inverted는 thresh 값을 기준으로 초과 값은 0, 이하는 원래 값 그대로 변환한다.


다음은 MFC를 이용하여 세가지의 값을 자유조절하면서 변환하는 이미지를 살펴보겠다.




컴퓨터 비전과 영상 처리에 대해 독학을 하면서 정리한 걸 적고 있습니다.

전공과 무관하며 전문적인 지식이 아니므로 개인적인 의견과 부족하고 틀린 점이 많습니다.

추가 지식 및 잘못된 점을 지적해주시면 공부하는데 많은 도움이 되겠습니다. 감사합니다^^

- 푸어맨


[Reference]

(threshold) http://docs.opencv.org/3.0-beta/modules/cudaarithm/doc/element_operations.html#double cuda::threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type, Stream& stream)

+ Recent posts