/* Types of thresholding */
#define CV_THRESH_BINARY 0 /* value = value > threshold ? max_value : 0 */
#define CV_THRESH_BINARY_INV 1 /* value = value > threshold ? 0 : max_value */
#define CV_THRESH_TRUNC 2 /* value = value > threshold ? threshold : value */
#define CV_THRESH_TOZERO 3 /* value = value > threshold ? value : 0 */
#define CV_THRESH_TOZERO_INV 4 /* value = value > threshold ? 0 : value */
#define CV_THRESH_MASK 7
#define CV_THRESH_OTSU 8 /* use Otsu algorithm to choose the optimal threshold value;
combine the flag with one of the above CV_THRESH_* values */
/* Applies fixed-level threshold to grayscale image.
This is a basic operation applied before retrieving contours */
CVAPI(double) cvThreshold( const CvArr* src, CvArr* dst,
double threshold, double max_value,
int threshold_type );
#define CV_ADAPTIVE_THRESH_MEAN_C 0
#define CV_ADAPTIVE_THRESH_GAUSSIAN_C 1
/* Applies adaptive threshold to grayscale image.
The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and
CV_ADAPTIVE_THRESH_GAUSSIAN_C are:
neighborhood size (3, 5, 7 etc.),
and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) */
CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C),
int threshold_type CV_DEFAULT(CV_THRESH_BINARY),
int block_size CV_DEFAULT(3),
double param1 CV_DEFAULT(5));
opencv 调用如下:cvAdaptiveThreshold( s, dst, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY_INV, 5, 15 ); s:输入单通道数据
dst :输出单通道数据
block_size CV_Assert( blockSize % 2 == 1 && blockSize > 1 ) 为奇数 为邻域大小
param1 加权平均减去的值
本文介绍了OpenCV中固定阈值处理与自适应阈值处理的基本概念及使用方法。固定阈值处理是一种基本操作,常用于轮廓检索前的预处理。自适应阈值处理则适用于背景光照变化的情况,通过调整局部阈值来实现更好的效果。
2万+

被折叠的 条评论
为什么被折叠?



