High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
Matlab practical ---5.pdf
1. MATLAB ASHOKA BAIRWA
PRACTICAL-5
Aim: Write a MATLAB code for adjusting the contrast of an image and plot contrast and intensity histogram.
Theory:
• Histogram equalization involves transforming the intensity values so that the histogram of the output
image approximately matches a specified histogram.
• By default, the histogram equalization function, histeq, tries to match a flat histogram with 64 bins
such that the output image has pixel values evenly distributed throughout the range.
• You can also specify a different target histogram to match a custom contrast.
histeq
Enhance contrast using histogram equalization
Syntax:
J = histeq(I)
J = histeq(I,n) J =
histeq(I,hgram) newmap =
histeq(X,map) newmap =
histeq(X,map,hgram)
[___,T] = histeq(___)
2. MATLAB ASHOKA BAIRWA
J = histeq(I) transforms the grayscale image I so that the histogram of the output grayscale image J has
64 bins and is approximately flat.
Read an image into the workspace.
Enhance the contrast of an intensity image using histogram equalization.
Display the original image and the adjusted image.
J = histeq(I,n) transforms the grayscale image I so that the histogram of the output grayscale image J
with n bins is approximately flat. The histogram of J is flatter when n is much smaller than the number of
discrete levels in I.
J = histeq(I,hgram) transforms the grayscale image I so that the histogram of the output grayscale
image J with length(hgram) bins approximately matches the target histogram hgram.
newmap = histeq(X,map) transforms the values in the colormap so that the histogram of the gray
component of the indexed image X is approximately flat. The transformed colormap is newmap.
3. MATLAB ASHOKA BAIRWA
newmap = histeq(X,map,hgram) transforms the colormap associated with the indexed image X so that
the histogram of the gray component of the indexed image (X,newmap) approximately matches the target
histogram hgram. The histeq function returns the transformed colormap in newmap. length(hgram)
must be the same as size(map,1).
[___,T] = histeq(___) also returns the transformation T that maps the gray component of the input
grayscale image or colormap to the gray component of the output grayscale image or colormap.
Read image into the workspace.
Adjust the contrast using histogram equalization, using the histeq function. Specify the gray scale
transformation return value, T, which is a vector that maps graylevels in the intensity image I to gray
levels in J.
Plot the transformation curve. Notice how this curve reflects the histograms in the previous figure, with the
input values mostly between 0.3 and 0.6, while the output values are distributed evenly between 0 and 1.
Plot Transformation Curve for Histogram Equalization
shows how to plot the transformation curve for histogram equalization. histeq can return a 1-by-256 vector
that shows, for each possible input value, the resulting output value. (The values in this vector are in the range
[0,1], regardless of the class of the input image.) You can plot this data to get the transformation curve.
[J,T] = histeq(I);
4. MATLAB ASHOKA BAIRWA
Original Image Histogram
• Read a grayscale image into the workspace.
I = imread
• Display the image and its histogram. The original image has low contrast, with most pixel values in the
middle of the intensity range.
5. MATLAB ASHOKA BAIRWA
Adjust Contrast Using Default Equalization
Adjust the contrast using histogram equalization. Use the default behavior of the histogram equalization
function, histeq. The default target histogram is a flat histogram with 64 bins.
J = histeq(I);
Display the contrast-adjusted image and its new histogram.
6. MATLAB ASHOKA BAIRWA
Adjust Contrast, Specifying Number of Bins
Adjust the contrast, specifying a different number of bins. With a small number of bins, there are noticeably
fewer gray levels in the contrast-adjusted image.
Display the contrast-adjusted image and its new histogram.
7. MATLAB ASHOKA BAIRWA
Adjust Contrast, Specifying Target Distribution
Adjust the contrast, specifying a nonflat target distribution.
This example demonstrates a linearly decreasing target histogram, which emphasizes small pixel values and
causes shadows to appear darker. Display the target histogram.
8. MATLAB ASHOKA BAIRWA
Adjust the histogram of the image to approximately match the target histogram.
Adjust the histogram of the image to approximately match the target histogram.
Display the contrast-adjusted image and its new histogram.
9. MATLAB ASHOKA BAIRWA
Enhance Contrast of Volumetric Image Using Histogram Equalization
Load a 3-D dataset.
Perform histogram equalization.
Display the first slice of data for the original image and the contrast-enhanced image.