您的位置:首页 > 运维架构

opencv中阈值函数处理

2014-04-19 18:37 459 查看
opencv2.46

函数:threshold

函数的原型如下:

//! applies fixed threshold to the image

double threshold( InputArray src, OutputArray dst, double thresh, double maxval, int type );

src – input array (single-channel, 8-bit or 32-bit floating point):输入元素必须是单通道,8位的数或32位的浮点数
dst – output array of the same size and type as src.:输出和输入应该有相同的大小和类型

type的类型有如下:

/* 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 */
};




例:threshold(ROI_image, binary_img, thres, MAX_VALUE,CV_THRESH_BINARY);

当ROI_image中的value > thres的时候,value设置为MAX_VALUE,否则设置为 0 。

参考:

1.opencv官方文档 opencv官方文档 opencv官方文档 opencv官方文档 opencv官方文档 opencv官方文档 opencv官方文档 opencv官方文档 opencv官方文档 opencv官方文档 opencv官方文档 :threshold
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: