How To Convert RGB To Grayscale Pic If: The Input Image I Can Be of Class Uint8
How To Convert RGB To Grayscale Pic If: The Input Image I Can Be of Class Uint8
be nonsparse. The return value level is a double scalar. The effectiveness metric EM
is a double scalar.
I = imread('coins.png');
level = graythresh(I);
BW = im2bw(I,level);
imshow(BW)
**graytresh is an otsu method
http://www.mathworks.com/help/images/ref/graythresh.html
im2bw
Convert image to binary image, based on threshold
http://www.mathworks.com/help/images/ref/im2bw.html
You can perform certain conversions just using MATLAB syntax. For example, you can convert a grayscale image to
truecolor format by concatenating three copies of the original matrix along the third dimension.
RGB = cat(3,I,I,I);
The resulting truecolor image has identical matrices for the red, green, and blue planes, so the image displays as
shades of gray.
In addition to these image type conversion functions, there are other functions that return a different image type as
part of the operation they perform. For example, the region of interest functions return a binary image that you can
use to mask an image for filtering or for other operations.
Note When you convert an image from one format to another, the resulting image might look different from the original. F
indexed image to a grayscale image, the resulting image displays as shades of grays, not color.
Function
Description
demosaic
dither
Use dithering to convert a grayscale image to a binary image or to convert a truecolor image to an indexed imag
gray2ind
grayslice
im2bw
Convert a grayscale image, indexed image, or truecolor image, to a binary image, based on a luminance thresho
ind2gray
ind2rgb
mat2gray
rgb2gray
Note: To work with images that use other color spaces, such as HSV, first convert the image to RGB, process th
original color space. For more information about color space conversion routines, see Color.
rgb2ind
ind2gray
mat2gray
rgb2gray
ind2rgb
label2rgb
demosaic
imquantize Quantize image using specified quantization levels and output values
multithresh Multilevel image thresholds using Otsu's method
im2bw
graythresh
grayslice
Convert grayscale image to indexed image using multilevel
thresholding
im2double
im2int16
im2java2d
im2single
im2uint16
im2uint8
http://www.mathworks.com/help/images/image-type-conversions.html