Академический Документы
Профессиональный Документы
Культура Документы
Lecture2:HistogramsandPoint
Operations(Part1)
ProfEmmanuelAgu
ComputerScienceDept.
WorcesterPolytechnicInstitute(WPI)
Histograms
Histogramsplotshowmanytimes(frequency)each
intensityvalueinimageoccurs
Example:
Image(left)has256distinctgraylevels(8bits)
Histogram(right)showsfrequency(howmanytimes)each
grayleveloccurs
Histograms
Manycamerasdisplayrealtimehistogramsofscene
Helpsavoidtakingoverexposedpictures
Alsoeasiertodetecttypesofprocessingpreviously
appliedtoimage
Histograms
Intensity
values
E.g.K =16,10pixelshaveintensityvalue=2
Histograms:onlystatisticalinformation
Noindicationoflocationofpixels
Histograms
Differentimagescanhavesamehistogram
3imagesbelowhavesamehistogram
Halfofpixelsaregray,halfarewhite
Samehistogram=samestatisics
Distributionofintensitiescouldbedifferent
Canwereconstructimagefromhistogram?No!
Histograms
So,ahistogramforagrayscaleimagewithintensity
valuesinrange
wouldcontainexactlyK entries
E.g.8bitgrayscaleimage,K= 28 =256
Eachhistogramentryisdefinedas:
h(i)=numberofpixelswithintensityIforall0<i <K.
E.g:h(255)=numberofpixelswithintensity=255
Formaldefinition
Number (size of set) of pixels such that
InterpretingHistograms
Logscalemakeslowvaluesmorevisible
Difference between darkest and lightest
Histograms
Histogramshelpdetectimageacquisitionissues
Problemswithimagecanbeidentifiedonhistogram
Overandunderexposure
Brightness
Contrast
DynamicRange
Pointoperationscanbeusedtoalterhistogram.E.g
Addition
Multiplication
ExpandLog
IntensityWindowing(ContrastModification)
ImageBrightness
Brightnessofagrayscaleimageistheaverage
intensity ofallpixelsinimage
Image
Histogram
Image
Histogram
Michalsonsequationforcontrast
ContrastEquation?
Theseequationsworkwellforsimpleimageswith2
luminances(i.e.uniformforegroundand
background)
Doesnotworkwellforcomplexsceneswithmany
luminancesorifminandmaxintensitiesaresmall
HistogramsandDynamicRange
DynamicRange:Numberofdistinctpixelsinimage
Difficulttoincreaseimagedynamicrange(e.g.interpolation)
HDR(1214bits)capturetypical,thendownsample
HighDynamicRangeImaging
Highdynamicrangemeansverybrightandverydark
partsinasingleimage(manydistinctvalues)
Dynamicrangeinphotographedscenemayexceed
numberofavailablebitstorepresentpixels
Solution:
Capturemultipleimagesatdifferentexposures
Combinethemusingimageprocessing
DetectingImageDefectsusingHistograms
Nobesthistogramshape,dependsonapplication
Imagedefects
Saturation:sceneilluminationvaluesoutsidethesensorsrangeare
settoitsminormaxvalues=>resultsinspikeatendsofhistogram
SpikesandGapsinmanipulatedimages(notoriginal).Why?
ImageDefects:EffectofImageCompression
Histogramsshowimpactofimagecompression
Example:inGIFcompression,dynamicrangeisreduced
toonlyfewintensities(quantization)
Original
Histogram
Original histogram
has only 2 intensities
(gray and white)
Returns histogram as an
array of integers
LargeHistograms:Binning
Highresolutionimagecanyieldverylargehistogram
Example:32bitimage=232 =4,294,967,296columns
Suchalargehistogramimpracticaltodisplay
Solution?Binning!
Combinerangesofintensityvaluesintohistogramcolumns
Example:Tocreate256binsfrom14bitimage
BinnedHistogram
Increment corresponding
histogram
ColorImageHistograms
Twotypes:
1. Intensityhistogram:
Convertcolor
imagetograyscale
Displayhistogram
ofgrayscale
2. IndividualColor
ChannelHistograms:
3histograms(R,G,B)
ColorImageHistograms
Bothtypesofhistogramsprovideusefulinformationabout
lighting,contrast,dynamicrangeandsaturationeffects
Noinformationabouttheactualcolordistribution!
ImageswithtotallydifferentRGBcolorscanhavesameR,G
andBhistograms
SolutiontothisambiguityistheCombinedColorHistogram.
Moreonthislater
CumulativeHistogram
Usefulforcertainoperations(e.g.histogramequalization)later
AnalogoustotheCumulativeDensityFunction(CDF)
Definition:
Recursivedefinition
Monotonicallyincreasing
Alsocalledahomogeneousoperation
Newpixelintensitydependson
PixelspreviousintensityI(u,v)
Mappingfunctionf()
Doesnotdependon
Pixelslocation(u,v)
Intensitiesofneighboringpixels
SomeHomogeneousPointOperations
Addition(Changesbrightness)
Multiplication(Stretches/shrinksimagecontrastrange)
Realvaluedfunctions
Quantizingpixelvalues
Globalthresholding
Gammacorrection
PointOperationPseudocode
Input:ImagewithpixelintensitiesI(u,v)definedon
[1..w]x[1..H]
Output:ImagewithpixelintensitiesI(u,v)
forv=1..h
foru=1..w
setI(u, v)=f(I(u,v))
NonHomogeneousPointOperation
Newpixelvaluedependson:
Oldvalue+pixelslocation(u,v)
Clamping
Dealswithpixelvaluesoutsidedisplayablerange
If(a>255)a=255;
If(a<0)a=0;
Functionbelowwillclamp(force)allvaluestofall
withinrange[a,b]
Example:ModifyIntensityandClamp
Pointoperation:increaseimagecontrastby50%
thenclampvaluesabove255
Increase contrast
by 50%
InvertingImages
2steps
1. Multipleintensityby1
2. Addconstant(e.g.amax)
toputresultinrange
[0,amax]
Implementedas
ImageJ method
invert( )
Original Inverted Image
ImageNegatives(InvertedImages)
Imagenegativesusefulforenhancingwhiteor
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
greydetailembeddedindarkregionsofanimage
Notehowmuchclearerthetissueisinthenegative
imageofthemammogrambelow
Original Negative
s = 1.0 - r
Image Image
Thresholding
Thresholdingsplitshistogram,mergeshalvesintoa0 a1
BasicGreyLevelTransformations
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
3mostcommongrayleveltransformation:
Linear
Negative/Identity
Logarithmic
Log/Inverselog
Powerlaw
nth power/nth root
LogarithmicTransformations
Mapsnarrowrangeofinputlevels=>widerrangeof
outputvalues
Inverselogtransformationdoesoppositetransformation
Thegeneralformofthelogtransformationis
New pixel value s = c * log(1 + r) Old pixel value
LogtransformationofFouriertransformshowsmoredetail
s = log(1 + r)
PowerLawTransformations
Powerlawtransformationshavetheform
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Power
s=c*r
Mapnarrowrangeof
darkinputvaluesinto
widerrangeofoutput
valuesorviceversa
Varying givesawhole
familyofcurves
PowerLawExample
Original
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
MagneticResonance
(MR)imageoffractured s = r 0.6
humanspine
s = r 0.4
Differentpowervalues
highlightdifferent
details
IntensityWindowing
Aclampoperation,thenlinearlystretchingimage
intensitiestofillpossiblerange
Towindowanimagein[a,b]withmaxintensityM
IntensityWindowingExample
Contrasts
easier to see
PointOperationsandHistograms
Effectofsomepointoperationseasiertoobserveonhistograms
Increasingbrightness
Raisingcontrast
Invertingimage
Pointoperationsonlyshift,mergehistogramentries
Operationsthatmergehistogrambinsareirreversible
Combining histogram
operation easier to
observe on histogram
AutomaticContrastAdjustment
Linearly stretching
range causes gaps
in histogram
HistogramEqualization
Adjust2differentimagestomaketheirhistograms
(intensitydistributions)similar
Applyapointoperationthatchangeshistogramof
modifiedimageintouniformdistribution
Histogram
Cumulative
Histogram
HistogramEqualization
Spreadingoutthefrequenciesinanimage(or
equalizingtheimage)isasimplewaytoimprovedark
orwashedoutimages
Canbeexpressedasatransformationofhistogram
rk: inputintensity
sk: processedintensity
k: theintensityrange
(e.g0.0 1.0)
Intensity range
(e.g 0 255)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
EqualizationTransformationFunction
EqualizationTransformationFunctions
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Differentequalizationfunction(14)maybeused
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
EqualizationExamples
1
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
EqualizationExamples
2
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
EqualizationExamples
4
3
References
WilhelmBurgerandMarkJ.Burge,DigitalImage
Processing,Springer,2008
Histograms(Ch 4)
Pointoperations(Ch 5)
UniversityofUtah,CS4640:ImageProcessingBasics,
Spring2012
RutgersUniversity,CS334,IntroductiontoImaging
andMultimedia,Fall2012
GonzalesandWoods,DigitalImageProcessing(3rd
edition),PrenticeHall