码迷,mamicode.com
首页 > 其他好文 > 详细

OpenCV图像的全局阈值二值化函数(OTSU)

时间:2015-07-25 12:12:03      阅读:310      评论:0      收藏:0      [点我收藏+]

标签:

cv::threshold(GrayImg, Bw, 0, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);//灰度图像二值化

CV_THRESH_OTSU是提取图像最佳阈值算法。该方法在类间方差最大的情况下是最佳的,就图像的灰度值而言,OTSU给出最好的类间分离的阈值。

 

OpenCV阈值分割的几种方法(types_c.h中的定义):

/* Threshold types */
enum
{
    CV_THRESH_BINARY      =0,  /* value = value > threshold ? max_value : 0       */
    CV_THRESH_BINARY_INV  =1,  /* value = value > threshold ? 0 : max_value       */
    CV_THRESH_TRUNC       =2,  /* value = value > threshold ? threshold : value   */
    CV_THRESH_TOZERO      =3,  /* value = value > threshold ? value : 0           */
    CV_THRESH_TOZERO_INV  =4,  /* value = value > threshold ? 0 : value           */
    CV_THRESH_MASK        =7,
    CV_THRESH_OTSU        =8  /* use Otsu algorithm to choose the optimal threshold value;
                                 combine the flag with one of the above CV_THRESH_* values */
}

 

OpenCV图像的全局阈值二值化函数(OTSU)

标签:

原文地址:http://www.cnblogs.com/meadow-glog/p/4675548.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!