In matlab there is a function rgb2gray() to convert rgb image into gray scale image.
we can do this manually also.
we can do this manually also.
- rgb = imread('Sun.jpg');
- figure('name','Original Image')
- imshow(rgb);
- gray_manual = 0.2989 * rgb(:,:,1) + 0.5870 * rgb(:,:,2) + 0.1140 * rgb(:,:,3);
- figure
- imshow(gray_manual);
Output
Original Image
Converted GrayScale Image
Formula to do this isIntensity = 0.2980 * red + 0.5870 * green + 0.1140 * blue