Registration : 21mic7178 Name : Sai Sanjay K
Title: Image Enhancement using Contrast Stretching and Histogram Equalization
Objective: The objective of this project is to demonstrate the use of spatial domain filtering techniques, namely contrast stretching and histogram equalization, to enhance the visual quality and contrast of a low-contrast image.
Software Tools: The code provided is written in MATLAB, a high-level programming language and numerical computing environment widely used in various scientific and engineering applications, including image processing.
Theory:
-
Contrast Stretching:
- Contrast stretching is a spatial domain technique used to enhance the contrast of an image.
- It works by expanding the range of pixel intensities in the image to better utilize the available dynamic range.
- This process is particularly useful for low-contrast images, where the pixel values are concentrated in a small range of the available gray-scale values.
-
Histogram and Histogram Equalization:
- The histogram of an image represents the distribution of pixel intensities within the image.
- Histogram equalization is a technique that modifies the histogram of an image to achieve a more uniform distribution of pixel values.
- This process can enhance the contrast of the image by spreading out the most frequent pixel values.
Coding using MATLAB: The provided MATLAB code demonstrates the following steps:
- Loading the image and converting it to gray-scale.
- Applying contrast stretching using the
imadjustfunction. - Performing histogram equalization using the
histeqfunction. - Displaying the original image, the gray-scale image, the contrast-enhanced images, and the histograms.
% Image Enhancement
i = imread('image.jpg');
subplot(2,2,1);
imshow(i);
title('Original Image');
g = rgb2gray(i);
subplot(4,2,5), imshow(g);
title('Gray Image');
j = imadjust(g, [0.3, 0.7], []);
subplot(4,2,3);
imshow(j);
title('Enhanced Image 1');
% Corrected line:
D = imadjust(j, [0.2, 0.8], []); % Changed from [0.2,0.3, 0.6,1] to [0.2, 0.8]
subplot(4,2,4);
imshow(D);
title('Enhanced Image 2');
% Histogram and histogram equalisation
subplot(4,2,7);
imhist(g);
title('Histogram of Gray Image');
% Histogram equalization
he = histeq(g);
subplot(4,2,6);
imshow(he);
title('Histogram Equalized');
% Display histogram of equalized image
subplot(4,2,8);
imhist(he);
title('Histogram of Equalized Image');
% Adjust figure properties for better visibility
set(gcf, 'Position', get(0, 'Screensize'));Sample Results: The provided image shows the results of the image enhancement process. The original low-contrast image is transformed using contrast stretching and histogram equalization, resulting in improved contrast and better visibility of image details.
Conclusion:
The MATLAB code presented demonstrates the effectiveness of spatial domain filtering techniques, particularly contrast stretching and histogram equalization, in enhancing the visual quality and contrast of a low-contrast image. These techniques are widely used in various image processing applications to improve the visibility and analysis of images.