您的位置:首页 > 其它

彩色图像,二值图像,灰度图像,不要傻傻分不清~

2015-05-30 17:12 211 查看
<pre id="best-content-300622303" class="best-text mb-10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; background-color: rgb(241, 254, 221); padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace;">(一)彩色图像
每个像素通常是由红(R)、绿(G)、蓝(B)三个分量来表示的,分量介于(0,255)。
Scalar(0,0,0):黑色 Scalar(255,255,255):白色(二)二值图像(binary image)

即图像上的每一个像素只有两种可能的取值或灰度等级状态,人们经常用黑白、B&W、单色图像表示二值图像。
threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type)
(输入图像,输出图像,阈值,最大值,type)
其中,type:(1)THRESH_BINARY
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">                                                  dst(x; y) =    maxval                 if src(x; y) > thresh
0                          otherwise
•                  (2) THRESH_BINARY_INV   </span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">                                                   dst(x; y) =     0                        if src(x; y) > thresh
maxval                      otherwise
(3)THRESH_TRUNC      </span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">                                                  dst(x; y) =   threshold               if src(x; y) > thresh
src(x; y)                      otherwise
•                   (4) THRESH_TOZERO</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">                                                  dst(x; y) =    src(x; y)                 if src(x; y) > thresh
0                            otherwise
•                     (5) THRESH_TOZERO_INV
dst(x; y) =        0                         if src(x; y) > thresh
src(x; y)                       otherwise</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">(三)灰度图像(gray image)</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">每个像素只有一个采样颜色的图像,这类图像通常显示为从最暗黑色到最亮的白色的灰度。</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">灰度图像与黑白图像不同,在计算机图像领域中黑白图像只有黑色与白色两种颜色;但是,灰度图像在黑色与白色之间还有许多级的颜色深度。</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">Mat image=imread("1.jpg",0);   0:即为gray的意思</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">或者</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">cvtColor(InputArray src, OutputArray dst, int code, int dstCn=0 )
</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">               (输入,输出,颜色空间转换模式,目标图像上的通道数量)</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;"></span><pre id="best-content-300622303" class="best-text mb-10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; background-color: rgb(241, 254, 221); padding: 0px;"><span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">颜色空间转换模式:RGB -> GRAY ( CV_BGR2GRAY, CV_RGB2GRAY, CV_GRAY2BGR, CV_GRAY2RGB ) </span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">                                RGB -> CIE XYZ.Rec 709 with D65 white point ( CV_BGR2XYZ, CV_RGB2XYZ, CV_XYZ2BGR, CV_XYZ2RGB)
</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">                                RGB->YCrCb JPEG (or YCC) ( CV_BGR2YCrCb, CV_RGB2YCrCb, CV_YCrCb2BGR, CV_YCrCb2RGB )
</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">                               RGB$HSV ( CV_BGR2HSV, CV_RGB2HSV, CV_HSV2BGR, CV_HSV2RGB )
</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">                              RGB$HLS ( CV_BGR2HLS, CV_RGB2HLS, CV_HLS2BGR, CV_HLS2RGB ).</span>
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px;">                               ……</span>


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