SlideShare a Scribd company logo
1 of 9
Download to read offline
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(___)
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.
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);
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.
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.
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.
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.
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.
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.

More Related Content

Similar to Matlab practical ---5.pdf

project presentation-90-MCS-200003.pptx
project presentation-90-MCS-200003.pptxproject presentation-90-MCS-200003.pptx
project presentation-90-MCS-200003.pptxNiladriBhattacharjee10
 
Intensity Transformation and Spatial filtering
Intensity Transformation and Spatial filteringIntensity Transformation and Spatial filtering
Intensity Transformation and Spatial filteringShajun Nisha
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.pptSKILL2021
 
05 histogram processing DIP
05 histogram processing DIP05 histogram processing DIP
05 histogram processing DIPbabak danyal
 
_Histogram.ppt............................
_Histogram.ppt............................_Histogram.ppt............................
_Histogram.ppt............................MuhammadKhalil858111
 
chapter-2.1 Histogram.ppt
chapter-2.1 Histogram.pptchapter-2.1 Histogram.ppt
chapter-2.1 Histogram.pptAyeleFeyissa1
 
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...Erdi Karaçal
 
Basics of Digital Images
Basics of  Digital ImagesBasics of  Digital Images
Basics of Digital ImagesSaad Al-Momen
 
Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...
Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...
Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...IJSRD
 
A comparative study of histogram equalization based image enhancement techniq...
A comparative study of histogram equalization based image enhancement techniq...A comparative study of histogram equalization based image enhancement techniq...
A comparative study of histogram equalization based image enhancement techniq...sipij
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit NotesAAKANKSHA JAIN
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)IJERD Editor
 
02 image processing
02 image processing02 image processing
02 image processingankit_ppt
 
Programming in matlab lesson5
Programming in matlab lesson5Programming in matlab lesson5
Programming in matlab lesson5najmah17
 
CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkTUOS-Sam
 
image processing intensity transformation
image processing intensity transformationimage processing intensity transformation
image processing intensity transformationalobaidimki
 

Similar to Matlab practical ---5.pdf (20)

project presentation-90-MCS-200003.pptx
project presentation-90-MCS-200003.pptxproject presentation-90-MCS-200003.pptx
project presentation-90-MCS-200003.pptx
 
Dip3
Dip3Dip3
Dip3
 
Intensity Transformation and Spatial filtering
Intensity Transformation and Spatial filteringIntensity Transformation and Spatial filtering
Intensity Transformation and Spatial filtering
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
05 histogram processing DIP
05 histogram processing DIP05 histogram processing DIP
05 histogram processing DIP
 
point operations in image processing
point operations in image processingpoint operations in image processing
point operations in image processing
 
_Histogram.ppt............................
_Histogram.ppt............................_Histogram.ppt............................
_Histogram.ppt............................
 
chapter-2.1 Histogram.ppt
chapter-2.1 Histogram.pptchapter-2.1 Histogram.ppt
chapter-2.1 Histogram.ppt
 
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
 
Basics of Digital Images
Basics of  Digital ImagesBasics of  Digital Images
Basics of Digital Images
 
Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...
Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...
Study on Contrast Enhancement with the help of Associate Regions Histogram Eq...
 
A comparative study of histogram equalization based image enhancement techniq...
A comparative study of histogram equalization based image enhancement techniq...A comparative study of histogram equalization based image enhancement techniq...
A comparative study of histogram equalization based image enhancement techniq...
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit Notes
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
 
02 image processing
02 image processing02 image processing
02 image processing
 
Programming in matlab lesson5
Programming in matlab lesson5Programming in matlab lesson5
Programming in matlab lesson5
 
CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & Coursework
 
image processing intensity transformation
image processing intensity transformationimage processing intensity transformation
image processing intensity transformation
 

More from Central university of Haryana

MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdfMATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdfCentral university of Haryana
 

More from Central university of Haryana (20)

Practical --2..pdf
Practical --2..pdfPractical --2..pdf
Practical --2..pdf
 
Practical --1.pdf
Practical --1.pdfPractical --1.pdf
Practical --1.pdf
 
ML Lab.docx
ML Lab.docxML Lab.docx
ML Lab.docx
 
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdfMATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
 
LittleBookOfRuby.pdf
LittleBookOfRuby.pdfLittleBookOfRuby.pdf
LittleBookOfRuby.pdf
 
all matlab_prog.pdf
all              matlab_prog.pdfall              matlab_prog.pdf
all matlab_prog.pdf
 
Practical13.docx
Practical13.docxPractical13.docx
Practical13.docx
 
Practical 111.docx
Practical 111.docxPractical 111.docx
Practical 111.docx
 
Matlab Practical--11.pdf
Matlab Practical--11.pdfMatlab Practical--11.pdf
Matlab Practical--11.pdf
 
Matlab Practical--11.docx
Matlab Practical--11.docxMatlab Practical--11.docx
Matlab Practical--11.docx
 
Matlab Practical--9.docx
Matlab Practical--9.docxMatlab Practical--9.docx
Matlab Practical--9.docx
 
Matlab Practical-- 12.pdf
Matlab Practical-- 12.pdfMatlab Practical-- 12.pdf
Matlab Practical-- 12.pdf
 
Matlab practical ---9.pdf
Matlab practical ---9.pdfMatlab practical ---9.pdf
Matlab practical ---9.pdf
 
Matlab practical ---7.pdf
Matlab practical ---7.pdfMatlab practical ---7.pdf
Matlab practical ---7.pdf
 
Matlab practical ---6.pdf
Matlab practical ---6.pdfMatlab practical ---6.pdf
Matlab practical ---6.pdf
 
Matlab practical ---4.pdf
Matlab practical ---4.pdfMatlab practical ---4.pdf
Matlab practical ---4.pdf
 
Matlab practical ---3.pdf
Matlab practical ---3.pdfMatlab practical ---3.pdf
Matlab practical ---3.pdf
 
Matlab practical ---2.pdf
Matlab practical ---2.pdfMatlab practical ---2.pdf
Matlab practical ---2.pdf
 
Matlab practical ---1.pdf
Matlab practical ---1.pdfMatlab practical ---1.pdf
Matlab practical ---1.pdf
 
Matlab practical --8.pdf
Matlab practical --8.pdfMatlab practical --8.pdf
Matlab practical --8.pdf
 

Recently uploaded

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 

Recently uploaded (20)

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
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.