简洁版翻译.
1 cvtColor
功能:改变图片颜色.
参数描述
序号 | 参数 | 描述 |
---|---|---|
1 | src | 输入图像数据,图像数据为无符号8位或无符号16位或单精度浮点型数据 |
2 | dst | 输出图像数据,保持与输入相同的尺寸和深度 |
3 | code | 图像转换编码,ColorConversionCodes |
4 | dstCn | 转换的图像通道数 |
图像转换码,常用,左右可互转.
序号 | 参数 | 描述 |
---|---|---|
1 | COLOR_BGR2BGRA | BGR三通道图像转为BGRA四通道图像 |
2 | COLOR_BGR2RGBA | BGR三通道转为RGBA四通道图形 |
3 | COLOR_BGR2GRAY | BGR三通道图像转为灰度图像 |
4 | COLOR_GRAY2BGR | 灰度图像转为三通道BGR图像 |
5 | COLOR_BGR2XYZ | BGR三通道图形转为XYZ图形 |
6 | COLOR_BGR2Luv | BGR三通道图形转为Luv图形 |
7 | COLOR_BGR2HLS | BGR三通道图形转为HLS图形 |
2 threshold()
功能:改变图形像素数值,将固定阈值与图形的每个像素值作用,输出改变后的数值dst及阈值retval;
参数描述
序号 | 参数 | 描述 |
---|---|---|
1 | src | 输入图像数据,单通道8位或32位浮点型数据 |
2 | dst | 输出数据,与输入数据同尺寸,同类型 |
3 | thresh | 阈值 |
4 | maxval | 最大值,使用THRESH_BINARY和THRESH_BINARY_INV计算dst |
5 | type | 阈值类别,查看ThresholdTypes |
3 ThresholdTypes
功能:根据阈值类型,获取阈值输出值;
序号 | 类型 | 计算方式 |
---|---|---|
1 | THRESH_BINARY | d s t ( x , y ) = { m a x v a l if s r c ( x , y ) > t h r e s h 0 othervise dst(x,y)=\begin{cases} maxval & \text {if $src(x,y)$ > $thresh$} \\ 0 & \text{othervise} \end {cases} dst(x,y)={maxval0if src(x,y) > threshothervise |
2 | THRESH_BINARY_INV | d s t ( x , y ) = { 0 if s r c ( x , y ) > t h r e s h m a x v a l otherwise dst(x, y)=\begin{cases} 0 &\text{if $src(x,y)$ > $thresh$} \\ maxval &\text{otherwise} \end{cases} dst(x,y)={0maxvalif src(x,y) > threshotherwise |
3 | THRESH_TRUNC | d s t ( x , y ) = { t h r e s h o l d if s r c ( x , y ) > t h r e s h s r c ( x , y ) otherwise dst(x, y)=\begin{cases} threshold &\text{if $src(x,y)$ > $thresh$} \\ src(x,y) &\text{otherwise} \end{cases} dst(x,y)={thresholdsrc(x,y)if src(x,y) > threshotherwise |
4 | THRESH_TOZERO | d s t ( x , y ) = { s r c ( x , y ) if s r c ( x , y ) > t h r e s h 0 ohterwise dst(x, y)=\begin{cases} src(x,y) &\text{if $src(x,y)$ > $thresh$} \\ 0 &\text{ohterwise} \end{cases} dst(x,y)={src(x,y)0if src(x,y) > threshohterwise |
5 | THRESH_TOZERO_INV | d s t ( x , y ) = { 0 if s r c ( x , y ) > t h r e s h s r c ( x , y ) otherwise dst(x, y)=\begin{cases} 0 &\text{if $src(x,y)$ > $thresh$} \\ src(x,y) &\text{otherwise} \end{cases} dst(x,y)={0src(x,y)if src(x,y) > threshotherwise |
6 | THRESH_MASK | |
7 | THRESH_OTSU | 标志位,使用Otsu算法选择优化的阈值 |
8 | THRESH_TRIANGLE | 标志位,使用Triangle算法选择优化的阈值 |
4 adaptiveThreshold()
功能:获取自适应阈值retval输出及图像输出dst;
参数描述
序号 | 参数 | 描述 |
---|---|---|
1 | src | 8位单通道图像数据 |
2 | dst | 输出的图像数据,与原图像同尺寸同通道数 |
3 | maxValue | 满足阈值条件的非零值,填充到对应像素点 |
4 | adaptiveMethod | 自适应算法,用于计算阈值 |
5 | thresholdType | 阈值类型,必须为THRESH_BINARY或THRESH_BINAYR_INV |
6 | blockSize | 计算阈值的像素区域尺寸,如3,5,7… |
7 | C | 从权重均值或均值中减去的常量,其值可正可负可零 |
5 AdaptiveThresholdTypes
功能:根据自适应阈值类型,获取阈值输出值;
参数描述
序号 | 参数 | 描述 |
---|---|---|
1 | ADAPTIVE_THRESH_MEAN_C | 阈值T(x,y)计算方式: T ( x , y ) = m e a n ( b l o c k S i z e × b l o c k S i z e ) − C T(x,y)=mean(blockSize\times blockSize)-C T(x,y)=mean(blockSize×blockSize)−C |
2 | ADAPTIVE_THRESH_GAUSSIAN_C | 阈值T(x,y)计算方式: T ( x , y ) = w e i g h t e d s u m ( b l o c k S i z e × b l o c k S i z e ) − C T(x,y)=weighted sum(blockSize\times blockSize)-C T(x,y)=weightedsum(blockSize×blockSize)−C |