08-16-2017, 08:47 PM
source code for contrast inhancement of image in matlab
Contrast enhancement of RGB images is done by processing the intensity component. Firstly convert image from RGB to YIQ, so as to be able to isolate the intensity component. Then apply histogram equalization to the intensity component, and convert back to RGB.
%% START %%
clc;
close all;
img=imread('a.bmp'); % save any color image as 'a.bmp'
x=rgb2ntsc(img);
x(:,:,1)=histeq(x(:,:,1));
c2=ntsc2rgb(x);
imshow(c2)
% apply histogram equalization to each of the RGB components:
% and put them all back into a single 3 dimensional array for use with imshow
rimg=histeq(img(:,:,1));
gimg=histeq(img(:,:,2));
bimg=histeq(img(:,:,3));
img=cat(3,rimg,gimg,bimg);
figure(2)
imshow(img)
%% END %%