close all clc clear all disp('Read the rgb image'); XX=imread('trees','JPEG'); % Provided by the instructor figure(1), imshow(XX); title('24-bit color'); disp('the grayscale image and histogram'); Y=rgb2gray(XX); %RGB to grayscale conversion figure(2), subplot(1, 2, 1);imshow(Y); title('original');subplot(1, 2, 2);imhist(Y, 256); disp('Equalization in grayscale domain'); Y=histeq(Y); figure(3), subplot(1, 2, 1);imshow(Y); title('EQ in grayscale-domain');subplot(1, 2, 2);imhist(Y, 256); disp('Equalization of Y channel for RGB color image'); figure(4) subplot(1, 2, 1);imshow(XX); title('EQ in RGB color'); subplot(1, 2, 2);imhist(rgb2gray(XX), 256); Z1=rgb2ntsc(XX); % Conversion from RGB to YIQ Z1(:,:,1)=histeq(Z1(:,:,1)); %Equalizing Y channel ZZ=ntsc2rgb(Z1); %Conversion from YIQ to RGB figure(5) subplot(1, 2, 1);imshow(ZZ); title('EQ for Y channel for RGB color image'); subplot(1, 2, 2);imhist(im2uint8(rgb2gray(ZZ)), 256); ZZZ=XX; ZZZ(:,:,1)=histeq(ZZZ(:,:,1)); %Equalizing R channel ZZZ(:,:,2)=histeq(ZZZ(:,:,2)); %Equalizing G channel ZZZ(:,:,3)=histeq(ZZZ(:,:,3)); %Equalizing B channel figure(6) subplot(1, 2, 1);imshow(ZZZ); title('EQ for RGB channels'); subplot(1, 2, 2);imhist(im2uint8(rgb2gray(ZZZ)), 256); disp('Equalization in 8-bit indexed color'); [Xind, map]=rgb2ind(XX, 256); % RGB to 8-bit index image conversion newmap=histeq(Xind, map); figure(7) subplot(1, 2, 1);imshow(Xind,newmap); title('EQ in 8-bit indexed color'); subplot(1, 2, 2);imhist(ind2gray(Xind,newmap), 256);