matlab(im2bw)

来源:互联网 发布:剑灵人族女捏脸数据 编辑:程序博客网 时间:2024/05/10 05:35

Something i lean in matlab. One sentence per day…..

IM2BW Convert image to binary image by thresholding.
    IM2BW produces binary images from indexed, intensity, or RGB images. To do
    this, it converts the input image to grayscale format (if it is not already
    an intensity image), and then converts this grayscale image to binary by
    thresholding(阀值控制在0-1之间,如果输入的是uint8类图像,则自动将所有像素点除以255,然后使用用户自定义的阀值或者是默认阀值0.5).                               The output binary image BW has values of 1 (white) for all
    pixels in the input image with luminance greater than LEVEL and 0 (black)
    for all other pixels. (Note that you specify LEVEL in the range [0,1],
    regardless of the class of the input image.)


    BW = IM2BW(I,LEVEL) converts the intensity image I to black and white.


    BW = IM2BW(X,MAP,LEVEL) converts the indexed image X with colormap MAP to black and white.


    BW = IM2BW(RGB,LEVEL) converts the RGB image RGB to black and white.


    Note that the function GRAYTHRESH can be used to compute LEVEL
    automatically.
    Class Support
    -------------
    The input image can be uint8, uint16, single, int16, or double and it
    must be nonsparse. The output image BW is logical. I and X must be 2-D.
    RGB images are M-by-N-by-3.

 

各个函数的使用:

im2uint8:将输入转化为uint8,有效的输入图像数据类型包括logical, uint8, uint16, double

im2uint16:将输入转化为uint16,有效的输入图像数据类型包括同上

mat2gray:将输入转化为double,但是输出的double数据都在[0, 1]范围内,有效的输入只有double

im2double:如果输入的不是double类型图像,在输出都是在[0, 1]范围,如uint8则输出为uint8/255。但如果是double类型,则原样输出

im2bw:上面已经解释了,输出的是二值图像。