Friday, 21 July 2017

How to Convert RGB image to grayscale

In this post, I am going to discuss about how to convert RGB or color map images into grayscale.

The following piece of code is used to convert RGB image to grayscale.


In the above code, grayimage = rgb2gray(I) converts the truecolor image RGB to the grayscale intensity image . The rgb2gray function converts RGB images to grayscale by eliminating the hue and saturation information while retaining the luminance.

DESCRIPTION:

Read and display an RGB image, and then convert it to grayscale.
Read the sample file, 1.jpg, and display the RGB image.
I = imread('1.jpg');
imshow(I);

Convert the RGB image to a grayscale image and display it.
grayimage = rgb2gray(I);
figure,
imshow(grayimage);

No comments:

Post a Comment