apply histogram equalization to three image with different illumination levels separately and compare the results in matlab

To apply histogram equalization to three separate images with varying illumination levels in Matlab, you can perform the following steps:

  1. Read in the three images using imread.
  2. Convert each image to grayscale using rgb2gray.
  3. Apply histogram equalization to each image using histeq.
  4. Display the original images and the equalized images side by side for comparison using subplot.

Here's the sample code:

main.m
% Read in the images
img1 = imread('image1.jpg');
img2 = imread('image2.jpg');
img3 = imread('image3.jpg');

% Convert the images to grayscale
gray1 = rgb2gray(img1);
gray2 = rgb2gray(img2);
gray3 = rgb2gray(img3);

% Apply histogram equalization to the images
eq1 = histeq(gray1);
eq2 = histeq(gray2);
eq3 = histeq(gray3);

% Display the original and equalized images side by side for comparison
subplot(3,4,1), imshow(img1), title('Image1 Orginal')
subplot(3,4,2), imshow(gray1), title('Gray1 Orginal')
subplot(3,4,3), imshow(eq1), title('Image1 Equalized')

subplot(3,4,5), imshow(img2), title('Image2 Orginal')
subplot(3,4,6), imshow(gray2), title('Gray2 Orginal')
subplot(3,4,7), imshow(eq2), title('Image2 Equalized')

subplot(3,4,9), imshow(img3), title('Image3 Orginal')
subplot(3,4,10), imshow(gray3), title('Gray3 Orginal')
subplot(3,4,11), imshow(eq3), title('Image3 Equalized')
890 chars
28 lines

The subplot function is used to arrange the six images (original and equalized images for each input image) in a 3x4 grid. The output will show the original images on the left and the equalized images on the right. You can visually compare the results for the three images to see the effect of histogram equalization on each image.

related categories

gistlibby LogSnag