opencv二值化函數cvThreshold

文章轉自http://blog.sina.com.cn/s/blog_8fc98fe501010vse.html

對圖像二值化函數cvThreshold的理解

Threshold

對數組元素進行固定閾值操作

void cvThreshold( const CvArr* src, CvArr* dst, double threshold, double max_value, int threshold_type );

src
原始數組 (單通道 , 8-bit of 32-bit 浮點數).
dst
輸出數組,必須與 src 的類型一致,或者爲 8-bit.
threshold
閾值
max_value
使用 CV_THRESH_BINARY 和 CV_THRESH_BINARY_INV 的最大值.
threshold_type
閾值類型 (見討論)

函數 cvThreshold 對單通道數組應用固定閾值操作。該函數的典型應用是對灰度圖像進行閾值操作得到二值圖像。(cvCmpS 也可以達到此目的) 或者是去掉噪聲,例如過濾很小或很大象素值的圖像點。本函數支持的對圖像取閾值的方法由 threshold_type 確定:

threshold_type=CV_THRESH_BINARY:

dst(x,y) = max_value, if src(x,y)>threshold 0, otherwise.

threshold_type=CV_THRESH_BINARY_INV:

dst(x,y) = 0, if src(x,y)>threshold; dst(x,y) = max_value, otherwise.

threshold_type=CV_THRESH_TRUNC:

dst(x,y) = threshold, if src(x,y)>threshold;   dst(x,y) = src(x,y), otherwise.

threshold_type=CV_THRESH_TOZERO:

dst(x,y) = src(x,y), if (x,y)>threshold ;  dst(x,y) = 0, otherwise.

threshold_type=CV_THRESH_TOZERO_INV:

dst(x,y) = 0, if src(x,y)>threshold ;  dst(x,y) = src(x,y), otherwise.

左面是圖形化的閾值描述:

2009年3月26日 - 老柯 - 菜鳥的朝聖之路


發佈了8 篇原創文章 · 獲贊 3 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章