DIP - Experiment No.4
DIP - Experiment No.4
: 04 Date of Performance:
Date of Submission:
AIM: To perform histogram equalization of a bad quality image and observe the difference
A. using Standard Matlab Function. B. Without using Standard Matlab Function.
n=number of pixels with k gray levels/total number of pixels. Figure 1 shows histogram of dark
bright low contrast and high contrast image.
Histogram equalization is a spatial domain method that produces output image with uniform
distribution of pixel intensity means that the histogram of the output image is flattened and
extended systematically. We acquire the probability density function (PDF) and cumulative
density function (CDF) via the input image histogram. Apply these two functions PDF and CDF
for replacing the input image gray levels to the new gray levels, and then we generate the
processed image and histogram for the resultant image. And when we discriminate input image
histogram with the processed image histogram we found that the gray level intensities are
stretched and depressed systematically.
The process of adjusting intensity values can be done automatically by the “HISTEQ” function.
“HISTEQ” performs histogram equalization, which involves transforming the intensity values so
that the histogram of the output image approximately matches a specified histogram.
Fig. 2 Histograms of images a) Dark b) Bright c) low contrast d) high contrast
2) HISTEQ
Enhance contrast using histogram equalization
Syntax
J = histeq(I,hgram)
J = histeq(I,n)
[J,T] = histeq(I,...)
Description
histeq enhances the contrast of images by transforming the values in an intensity image, or the
values in the colormap of an indexed image, so that the histogram of the output image
approximately matches a specified histogram. J = histeq(I,hgram) transforms the intensity image
I so that the histogram of the output intensity image J with length(hgram) bins approximately
matches hgram.
J = histeq(I,n) transforms the intensity image I, returning in J an intensity image with n discrete
gray levels.
[J,T] = histeq(I,...) returns the grayscale transformation that maps gray levels in the intensity
image I to gray levels in J.
ALGORITHM:
PROGRAM:
A. Using Standard Matlab Function.
clc;
clear all;
disp('Histogram Equalization of image')
I = imread('shadow.tif')
imview(I)
figure,imhist(I)
J=histeq(I)
imview(J)
figure,imhist(J)
[J,T] = histeq(I)
figure,plot((0:255)/255,T)