Sie sind auf Seite 1von 179

10/26/2016

DIPQuickGuide

DIPQuickGuide
Advertisements

PreviousPage

NextPage

DigitalImageProcessingIntroduction
Introduction
Signalprocessingisadisciplineinelectricalengineeringandinmathematicsthatdealswith
analysisandprocessingofanaloganddigitalsignals,anddealswithstoring,filtering,and
other operations on signals. These signals include transmission signals , sound or voice
signals,imagesignals,andothersignalse.t.c.
Outofallthesesignals,thefieldthatdealswiththetypeofsignalsforwhichtheinputisan
imageandtheoutputisalsoanimageisdoneinimageprocessing.Asitnamesuggests,it
dealswiththeprocessingonimages.
Itcanbefurtherdividedintoanalogimageprocessinganddigitalimageprocessing.

Analogimageprocessing
Analog image processing is done on analog signals. It includes processing on two
dimensional analog signals. In this type of processing, the images are manipulated by
electrical means by varying the electrical signal. The common example include is the
televisionimage.
Digitalimageprocessinghasdominatedoveranalogimageprocessingwiththepassageof
timedueitswiderrangeofapplications.

Digitalimageprocessing
Thedigitalimageprocessingdealswithdevelopingadigitalsystemthatperformsoperations
onandigitalimage.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

1/179

10/26/2016

DIPQuickGuide

WhatisanImage
Animageisnothingmorethanatwodimensionalsignal.Itisdefinedbythemathematical
functionf(x,y)wherexandyarethetwocoordinateshorizontallyandvertically.
Thevalueoff(x,y)atanypointisgivesthepixelvalueatthatpointofanimage.

Theabovefigureisanexampleofdigitalimagethatyouarenowviewingonyourcomputer
screen.Butactually,thisimageisnothingbutatwodimensionalarrayofnumbersranging
between0and255.
128

30

123

232

123

321

123

77

89

80

255

255

Eachnumberrepresentsthevalueofthefunctionf(x,y)atanypoint.Inthiscasethevalue
128,230,123eachrepresentsanindividualpixelvalue.Thedimensionsofthepictureis
actuallythedimensionsofthistwodimensionalarray.

Relationshipbetweenadigitalimageandasignal
Iftheimageisatwodimensionalarraythenwhatdoesithavetodowithasignal?Inorder
tounderstandthat,Weneedtofirstunderstandwhatisasignal?

Signal
Inphysicalworld,anyquantitymeasurablethroughtimeoverspaceoranyhigherdimension
can be taken as a signal. A signal is a mathematical function, and it conveys some
information. A signal can be one dimensional or two dimensional or higher dimensional
signal.Onedimensionalsignalisasignalthatismeasuredovertime.Thecommonexample
isavoicesignal.Thetwodimensionalsignalsarethosethataremeasuredoversomeother
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

2/179

10/26/2016

DIPQuickGuide

physicalquantities.Theexampleoftwodimensionalsignalisadigitalimage.Wewilllookin
more detail in the next tutorial of how a one dimensional or two dimensional single and
highersignalsareformedandinterpreted.

Relationship
Sinceanythingthatconveysinformationorbroadcastamessageinphysicalworldbetween
twoobserversisasignal.Thatincludesspeechor(humanvoice)oranimageasasignal.
Sincewhenwespeak,ourvoiceisconvertedtoasoundwave/signalandtransformedwith
respect to the time to person we are speaking to. Not only this , but the way a digital
camera works, as while acquiring an image from a digital camera involves transfer of a
signalfromonepartofthesystemtotheother.

Howadigitalimageisformed
Since capturing an image from a camera is a physical process. The sunlight is used as a
source of energy. A sensor array is used for the acquisition of the image. So when the
sunlightfallsupontheobject,thentheamountoflightreflectedbythatobjectissensedby
thesensors,andacontinuousvoltagesignalisgeneratedbytheamountofsenseddata.In
order to create a digital image , we need to convert this data into a digital form. This
involves sampling and quantization. (They are discussed later on). The result of sampling
andquantizationresultsinantwodimensionalarrayormatrixofnumberswhicharenothing
butadigitalimage.

Overlappingfields
Machine/Computervision
Machinevisionorcomputervisiondealswithdevelopingasysteminwhichtheinputisan
image and the output is some information. For example: Developing a system that scans
humanfaceandopensanykindoflock.Thissystemwouldlooksomethinglikethis.

Computergraphics
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

3/179

10/26/2016

DIPQuickGuide

Computergraphicsdealswiththeformationofimagesfromobjectmodels,ratherthenthe
image is captured by some device. For example: Object rendering. Generating an image
fromanobjectmodel.Suchasystemwouldlooksomethinglikethis.

Artificialintelligence
Artificialintelligenceismoreorlessthestudyofputtinghumanintelligenceintomachines.
Artificial intelligence has many applications in image processing. For example: developing
computer aided diagnosis systems that help doctors in interpreting images of Xray , MRI
e.t.candthenhighlightingconspicuoussectiontobeexaminedbythedoctor.

Signalprocessing
Signal processing is an umbrella and image processing lies under it. The amount of light
reflected by an object in the physical world (3d world) is pass through the lens of the
cameraanditbecomesa2dsignalandhenceresultinimageformation.Thisimageisthen
digitized using methods of signal processing and then this digital image is manipulated in
digitalimageprocessing.

SignalsandSystemsIntroduction
This tutorial covers the basics of signals and system necessary for understanding the
conceptsofdigitalimageprocessing.Beforegoingintothedetailconcepts,letsfirstdefine
thesimpleterms.

Signals
In electrical engineering, the fundamental quantity of representing some information is
calledasignal.Itdoesnotmatterwhattheinformationisie:Analogordigitalinformation.
Inmathematics,asignalisafunctionthatconveyssomeinformation.Infactanyquantity
measurable through time over space or any higher dimension can be taken as a signal. A
signalcouldbeofanydimensionandcouldbeofanyform.

Analogsignals
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

4/179

10/26/2016

DIPQuickGuide

Asignalcouldbeananalogquantitythatmeansitisdefinedwithrespecttothetime.Itisa
continuous signal. These signals are defined over continuous independent variables. They
aredifficulttoanalyze,astheycarryahugenumberofvalues.Theyareverymuchaccurate
due to a large sample of values. In order to store these signals , you require an infinite
memorybecauseitcanachieveinfinitevaluesonarealline.Analogsignalsaredenotedby
sinwaves.
Forexample:

Humanvoice
Humanvoiceisanexampleofanalogsignals.Whenyouspeak,thevoicethatisproduced
travel through air in the form of pressure waves and thus belongs to a mathematical
function,havingindependentvariablesofspaceandtimeandavaluecorrespondingtoair
pressure.
Anotherexampleisofsinwavewhichisshowninthefigurebelow.
Y=sin(x)wherexisindepedent

Digitalsignals
As compared to analog signals, digital signals are very easy to analyze. They are
discontinuoussignals.Theyaretheappropriationofanalogsignals.
Theworddigitalstandsfordiscretevaluesandhenceitmeansthattheyusespecificvalues
to represent any information. In digital signal , only two values are used to represent
somethingie:1and0(binaryvalues).Digitalsignalsarelessaccuratethenanalogsignals
becausetheyarethediscretesamplesofananalogsignaltakenoversomeperiodoftime.
Howeverdigitalsignalsarenotsubjecttonoise.Sotheylastlongandareeasytointerpret.
Digitalsignalsaredenotedbysquarewaves.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

5/179

10/26/2016

DIPQuickGuide

Forexample:

Computerkeyboard
Wheneverakeyispressedfromthekeyboard,theappropriateelectricalsignalissentto
keyboard controller containing the ASCII value that particular key. For example the
electricalsignalthatisgeneratedwhenkeyboardkeyaispressed,carryinformationofdigit
97intheformof0and1,whichistheASCIIvalueofcharactera.

Differencebetweenanaloganddigitalsignals
Comparison
element

Analogsignal

Digitalsignal

Analysis

Difficult

Possibletoanalyze

Representation

Continuous

Discontinuous

Accuracy

Moreaccurate

Lessaccurate

Storage

Infinitememory

Easilystored

SubjecttoNoise

Yes

No

Recording
Technique

Originalsignalispreserved

Samplesofthesignalaretakenand
preserved

Examples

Humanvoice,Thermometer,Analog
phonese.t.c

Computers,DigitalPhones,Digital
pens,e.t.c

Systems
Asystemisadefinedbythetypeofinputandoutputitdealswith.Sincewearedealingwith
signals , so in our case , our system would be a mathematical model , a piece of
code/software,oraphysicaldevice,orablackboxwhoseinputisasignalanditperforms
someprocessingonthatsignal,andtheoutputisasignal.Theinputisknownasexcitation
andtheoutputisknownasresponse.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

6/179

10/26/2016

DIPQuickGuide

Intheabovefigureasystemhasbeenshownwhoseinputandoutputbotharesignalsbut
the input is an analog signal. And the output is an digital signal. It means our system is
actuallyaconversionsystemthatconvertsanalogsignalstodigitalsignals.

Letshavealookattheinsideofthisblackboxsystem
Conversionofanalogtodigitalsignals
Since there are lot of concepts related to this analog to digital conversion and viceversa.
Wewillonlydiscussthosewhicharerelatedtodigitalimageprocessing.Therearetwomain
conceptsthatareinvolvedinthecoversion.
Sampling
Quantization

Sampling
Samplingasitsnamesuggestscanbedefinedastakesamples.Takesamplesofadigital
signal over x axis. Sampling is done on an independent variable. In case of this
mathematicalequation:

Samplingisdoneonthexvariable.Wecanalsosaythattheconversionofxaxis(infinite
values)todigitalisdoneundersampling.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

7/179

10/26/2016

DIPQuickGuide

Samplingisfurtherdivideintoupsamplinganddownsampling.Iftherangeofvaluesonx
axisarelessthenwewillincreasethesampleofvalues.Thisisknownasupsamplingand
itsviceversaisknownasdownsampling

Quantization
Quantization as its name suggest can be defined as dividing into quanta (partitions).
Quantizationisdoneondependentvariable.Itisoppositetosampling.
Incaseofthismathematicalequationy=sin(x)
Quantization is done on the Y variable. It is done on the y axis. The conversion of y axis
infinitevaluesto1,0,1(oranyotherlevel)isknownasQuantization.
These are the two basics steps that are involved while converting an analog signal to a
digitalsignal.
Thequantizationofasignalhasbeenshowninthefigurebelow.

Whydoweneedtoconvertananalogsignaltodigital
signal.
Thefirstandobviousreasonisthatdigitalimageprocessingdealswithdigitalimages,that
aredigitalsignals.Sowhenevertheimageiscaptured,itisconvertedintodigitalformat
andthenitisprocessed.
Thesecondandimportantreasonis,thatinordertoperformoperationsonananalogsignal
withadigitalcomputer,youhavetostorethatanalogsignalinthecomputer.Andinorder
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

8/179

10/26/2016

DIPQuickGuide

to store an analog signal , infinite memory is required to store it. And since thats not
possible,sothatswhyweconvertthatsignalintodigitalformatandthenstoreitindigital
computerandthenperformsoperationsonit.

Continuoussystemsvsdiscretesystems
Continuoussystems
Thetypeofsystemswhoseinputandoutputbotharecontinuoussignalsoranalogsignals
arecalledcontinuoussystems.

Discretesystems
Thetypeofsystemswhoseinputandoutputbotharediscretesignalsordigitalsignalsare
calleddigitalsystems

HistoryofPhotography
Originofcamera
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

9/179

10/26/2016

DIPQuickGuide

The history of camera and photography is not exactly the same. The concepts of camera
wereintroducedalotbeforetheconceptofphotography

CameraObscura
ThehistoryofthecameraliesinASIA.Theprinciplesofthecamerawerefirstintroducedby
aChinesephilosopherMOZI.Itisknownascameraobscura.Thecamerasevolvedfromthis
principle.
The word camera obscura is evolved from two different words. Camera and Obscura. The
meaningofthewordcameraisaroomorsomekindofvaultandObscurastandsfordark.
The concept which was introduced by the Chinese philosopher consist of a device, that
projectanimageofitssurroundingonthewall.HoweveritwasnotbuiltbytheChinese.

Thecreationofcameraobscura
TheconceptofChinesewasbringinrealitybyaMuslimscientistAbuAliAlHassanIbnal
HaithamcommonlyknownasIbnalHaitham.Hebuiltthefirstcameraobscura.Hiscamera
followstheprinciplesofpinholecamera.Hebuildthisdeviceinsomewherearound1000.

Portablecamera
In1685,afirstportablecamerawasbuiltbyJohannZahn.Beforetheadventofthisdevice,
thecameraconsistofasizeofroomandwerenotportable.Althoughadevicewasmadeby
anIrishscientistRobertBoyleandRobertHookethatwasatransportablecamera,butstill
thatdevicewasveryhugetocarryitfromoneplacetotheother.

Originofphotography
Althoughthecameraobscurawasbuiltin1000byaMuslimscientist.Butitsfirstactualuse
wasdescribedinthe13thcenturybyanEnglishphilosopherRogerBacon.Rogersuggested
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

10/179

10/26/2016

DIPQuickGuide

theuseofcamerafortheobservationofsolareclipses.

DaVinci
Although much improvement has been made before the 15th century , but the
improvementsandthefindingsdonebyLeonardodiserPierodaVinciwasremarkable.Da
Vinciwasagreatartist,musician,anatomist,andawarenginner.Heiscreditedformany
inventions.Hisoneofthemostfamouspaintingincludes,thepaintingofMonaLisa.

Davincinotonlybuiltacameraobscurafollowingtheprincipleofapinholecamerabutalso
usesitasdrawingaidforhisartwork.Inhiswork,whichwasdescribedinCodexAtlanticus
,manyprinciplesofcameraobscurahasbeendefined.

Hiscamerafollowstheprincipleofapinholecamerawhichcanbedescribedas
Whenimagesofilluminatedobjectspenetratethroughasmallholeintoaverydarkroom
youwillsee[ontheoppositewall]theseobjectsintheirproperformandcolor,reducedin
sizeinareversedposition,owingtotheintersectionofrays.

Firstphotograph
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

11/179

10/26/2016

DIPQuickGuide

Thefirstphotographwastakenin1814byaFrenchinventorJosephNicephoreNiepce.He
capturesthefirstphotographofaviewfromthewindowatLeGras,bycoatingthepewter
platewithbitumenandafterthatexposingthatplatetolight.

Firstunderwaterphotograph
ThefirstunderwaterphotographwastakenbyanEnglishmathematicianWilliamThomson
usingawatertightbox.Thiswasdonein1856.

Theoriginoffilm
The origin of film was introduced by an American inventor and a philanthropist known as
GeorgeEastmanwhoisconsideredasthepioneerofphotography.
HefoundedthecompanycalledasEastmanKodak,whichisfamousfordevelopingfilms.
Thecompanystartsmanufacturingpaperfilmin1885.HefirstcreatedthecameraKodak
andthenlaterBrownie.Browniewasaboxcameraandgainitspopularityduetoitsfeature
ofSnapshot.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

12/179

10/26/2016

DIPQuickGuide

Aftertheadventofthefilm,thecameraindustryonceagaingotaboomandoneinvention
leadtoanother.

LeicaandArgus
Leicaandargusarethetwoanalogcamerasdevelopedin1925andin1939respectively.
ThecameraLeicawasbuiltusinga35mmcinefilm.

Argus was another camera analog camera that uses the 35mm format and was rather
inexpensiveascomparedbyLeicaandbecameverypopular.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

13/179

10/26/2016

DIPQuickGuide

AnalogCCTVcameras
In1942aGermanengineerWalterBruchdevelopedandinstalledtheveryfirstsystemof
the analog CCTV cameras. He is also credited for the invention of color television in the
1960.

PhotoPac
Thefirstdisposablecamerawasintroducedin1949byPhotoPac.Thecamerawasonlya
onetimeusecamerawitharolloffilmalreadyincludedinit.ThelaterversionsofPhotopac
werewaterproofandevenhavetheflash.

DigitalCameras
MavicabySony
Mavica (the magnetic video camera) was launched by Sony in 1981 was the first game
changerindigitalcameraworld.Theimageswererecordedonfloppydisksandimagescan
beviewedlateronanymonitorscreen.
It was not a pure digital camera , but an analog camera. But got its popularity due to its
storingcapacityofimagesonafloppydisks.Itmeansthatyoucannowstoreimagesfora
long lasting period , and you can save a huge number of pictures on the floppy which are
replacedbythenewblankdisc,whentheygotfull.Mavicahasthecapacityofstoring25
imagesonadisk.
One more important thing that mavica introduced was its 0.3 mega pixel capacity of
capturingphotos.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

14/179

10/26/2016

DIPQuickGuide

DigitalCameras
FujiDS1PcamerabyFujifilms1988wasthefirsttruedigitalcamera
Nikon D1 was a 2.74 mega pixel camera and the first commercial digital SLR camera
developedbyNikon,andwasverymuchaffordablebytheprofessionals.

Today digital cameras are included in the mobile phones with very high resolution and
quality.

ApplicationsandUsage
Since digital image processing has very wide applications and almost all of the technical
fieldsareimpactedbyDIP,wewilljustdiscusssomeofthemajorapplicationsofDIP.
DigitalImageprocessingisnotjustlimitedtoadjustthespatialresolutionoftheeveryday
images captured by the camera. It is not just limited to increase the brightness of the
photo,e.t.c.Ratheritisfarmorethanthat.
Electromagnetic waves can be thought of as stream of particles, where each particle is
moving with the speed of light. Each particle contains a bundle of energy. This bundle of
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

15/179

10/26/2016

DIPQuickGuide

energyiscalledaphoton.
Theelectromagneticspectrumaccordingtotheenergyofphotonisshownbelow.

In this electromagnetic spectrum, we are only able to see the visible spectrum. Visible
spectrum mainly includes seven different colors that are commonly term as (VIBGOYR).
VIBGOYRstandsforviolet,indigo,blue,green,orange,yellowandRed.
But that doesnot nullify the existence of other stuff in the spectrum. Our human eye can
onlyseethevisibleportion,inwhichwesawalltheobjects.Butacameracanseetheother
thingsthatanakedeyeisunabletosee.Forexample:xrays,gammarays,e.t.c.Hence
theanalysisofallthatstufftooisdoneindigitalimageprocessing.
Thisdiscussionleadstoanotherquestionwhichis

whydoweneedtoanalyzeallthatotherstuffinEM
spectrumtoo?
Theanswertothisquestionliesinthefact,becausethatotherstuffsuchasXRayhasbeen
widely used in the field of medical. The analysis of Gamma ray is necessary because it is
usedwidelyinnuclearmedicineandastronomicalobservation.Samegoeswiththerest of
thethingsinEMspectrum.

ApplicationsofDigitalImageProcessing
Some of the major fields in which digital image processing is widely used are mentioned
below
Imagesharpeningandrestoration

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

16/179

10/26/2016

DIPQuickGuide

Medicalfield
Remotesensing
Transmissionandencoding
Machine/Robotvision
Colorprocessing
Patternrecognition
Videoprocessing
MicroscopicImaging
Others

Imagesharpeningandrestoration
Image sharpening and restoration refers here to process images that have been captured
from the modern camera to make them a better image or to manipulate those images in
waytoachievedesiredresult.ItreferstodowhatPhotoshopusuallydoes.
This includes Zooming, blurring , sharpening , gray scale to color conversion, detecting
edgesandviceversa,ImageretrievalandImagerecognition.Thecommonexamplesare:
Theoriginalimage

Thezoomedimage

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

17/179

10/26/2016

DIPQuickGuide

Blurrimage

Sharpimage

Edges

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

18/179

10/26/2016

DIPQuickGuide

Medicalfield
ThecommonapplicationsofDIPinthefieldofmedicalis
1. Gammarayimaging
2. PETscan
3. XRayImaging
4. MedicalCT
5. UVimaging

UVimaging
Inthefieldofremotesensing,theareaoftheearthisscannedbyasatelliteorfromavery
highgroundandthenitisanalyzedtoobtaininformationaboutit.Oneparticularapplication
ofdigitalimageprocessinginthefieldofremotesensingistodetectinfrastructuredamages
causedbyanearthquake.
Asittakeslongertimetograspdamage,evenifseriousdamagesarefocusedon.Sincethe
areaeffectedbytheearthquakeissometimessowide,thatitnotpossibletoexamineit
withhumaneyeinordertoestimatedamages.Evenifitis,thenitisveryhecticandtime
consumingprocedure.Soasolutiontothisisfoundindigitalimageprocessing.Animageof
theeffectedareaiscapturedfromtheabovegroundandthenitisanalyzedtodetectthe
varioustypesofdamagedonebytheearthquake.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

19/179

10/26/2016

DIPQuickGuide

Thekeystepsincludeintheanalysisare
1. Theextractionofedges
2. Analysisandenhancementofvarioustypesofedges

Transmissionandencoding
TheveryfirstimagethathasbeentransmittedoverthewirewasfromLondontoNewYork
viaasubmarinecable.Thepicturethatwassentisshownbelow.

Thepicturethatwassenttookthreehourstoreachfromoneplacetoanother.
Nowjustimagine,thattodayweareabletoseelivevideofeed,orlivecctvfootagefrom
onecontinenttoanotherwithjustadelayofseconds.Itmeansthatalotofworkhasbeen
doneinthisfieldtoo.Thisfielddoesnotonlyfocusontransmission,butalsoonencoding.
Manydifferentformatshavebeendevelopedforhighorlowbandwithtoencodephotosand
thenstreamitovertheinternetore.t.c.

Machine/Robotvision
Apartformthemanychallengesthatarobotfacetoday,oneofthebiggestchallengestillis
toincreasethevisionoftherobot.Makerobotabletoseethings,identifythem,identify

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

20/179

10/26/2016

DIPQuickGuide

thehurdlese.t.c.Muchworkhasbeencontributedbythisfieldandacompleteotherfieldof
computervisionhasbeenintroducedtoworkonit.

Hurdledetection
Hurdledetectionisoneofthecommontaskthathasbeendonethroughimageprocessing,
by identifying different type of objects in the image and then calculating the distance
betweenrobotandhurdles.

Linefollowerrobot
Mostoftherobotstodayworkbyfollowingthelineandthusarecalledlinefollowerrobots.
Thishelparobottomoveonitspathandperformsometasks.Thishasalsobeenachieved
throughimageprocessing.

Colorprocessing
Color processing includes processing of colored images and different color spaces that are
used.ForexampleRGBcolormodel,YCbCr,HSV.Italsoinvolvesstudyingtransmission,
storage,andencodingofthesecolorimages.

Patternrecognition
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

21/179

10/26/2016

DIPQuickGuide

Patternrecognitioninvolvesstudyfromimageprocessingandfromvariousotherfieldsthat
includesmachinelearning(abranchofartificialintelligence).Inpatternrecognition,image
processingisusedforidentifyingtheobjectsinanimagesandthenmachinelearningisused
totrainthesystemforthechangeinpattern.Patternrecognitionisusedincomputeraided
diagnosis,recognitionofhandwriting,recognitionofimagese.t.c

Videoprocessing
A video is nothing but just the very fast movement of pictures. The quality of the video
dependsonthenumberofframes/picturesperminuteandthequalityofeachframebeing
used. Video processing involves noise reduction , detail enhancement , motion detection ,
framerateconversion,aspectratioconversion,colorspaceconversione.t.c.

ConceptofDimensions
Wewilllookatthisexampleinordertounderstandtheconceptofdimension.

Consider you have a friend who lives on moon, and he wants to send you a gift on your
birthday present. He ask you about your residence on earth. The only problem is that the
courier service on moon doesnot understand the alphabetical address, rather it only
understandthenumericalcoordinates.Sohowdoyousendhimyourpositiononearth?
Thatswherecomestheconceptofdimensions.Dimensionsdefinetheminimumnumberof
pointsrequiredtopointapositionofanyparticularobjectwithinaspace.
Soletsgobacktoourexampleagaininwhichyouhavetosendyourpositiononearthto
your friend on moon. You send him three pair of coordinates. The first one is called
longitude,thesecondoneiscalledlatitude,andthethirdoneiscalledaltitude.
These three coordinates define your position on the earth. The first two defines your
location,andthethirdonedefinesyourheightabovethesealevel.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

22/179

10/26/2016

DIPQuickGuide

So that means that only three coordinates are required to define your position on earth.
That means you live in world which is 3 dimensional. And thus this not only answers the
questionaboutdimension,butalsoanswersthereason,thatwhyweliveina3dworld.
Sincewearestudyingthisconceptinreferencetothedigitalimageprocessing,soweare
nowgoingtorelatethisconceptofdimensionwithanimage.

Dimensionsofimage
Soifweliveinthe3dworld,meansa3dimensionalworld,thenwhatarethedimensionsof
an image that we capture. An image is a two dimensional, thats why we also define an
image as a 2 dimensional signal. An image has only height and width. An image doesnot
havedepth.Justhavealookatthisimagebelow.

Ifyouwouldlookattheabovefigure,itshowsthatithasonlytwoaxiswhicharetheheight
andwidthaxis.Youcannotperceivedepthfromthisimage.Thatswhywesaythatanimage
istwodimensionalsignal.Butoureyeisabletoperceivethreedimensionalobjects,butthis
would be more explained in the next tutorial of how the camera works , and image is
perceived.
Thisdiscussionleadstosomeotherquestionsthathow3dimensionsystemsisformedfrom
2dimension.

Howdoestelevisionworks?
If we look the image above , we will see that it is a two dimensional image. In order to
convertitintothreedimension,weneedoneotherdimension.Letstaketimeasthethird
dimension,inthatcasewewillmovethistwodimensionalimageoverthethirddimension
time. The same concept that happens in television, that helps us perceive the depth of
differentobjectsonascreen.DoesthatmeanthatwhatcomesontheT.Vorwhatweseein
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

23/179

10/26/2016

DIPQuickGuide

thetelevisionscreenis3d.Wellwecanyes.Thereasonisthat,incaseofT.Vweifweare
playingavideo.Thenavideoisnothingelsebuttwodimensionalpicturesmoveovertime
dimension.Astwodimensionalobjectsaremovingoverthethirddimensionwhichisatime
sowecansayitis3dimensional.

Differentdimensionsofsignals
1dimensionsignal
The common example of a 1 dimension signal is a waveform. It can be mathematically
representedas
F(x)=waveform
Wherexisanindependentvariable.Sinceitisaonedimensionsignal,sothatswhythereis
onlyonevariablexisused.
Pictorialrepresentationofaonedimensionalsignalisgivenbelow:

Theabovefigureshowsaonedimensionalsignal.
Nowthisleadtoanotherquestion,whichis,eventhoughitisaonedimensionalsignal,then
why does it have two axis?. The answer to this question is that even though it is a one
dimensionalsignal,butwearedrawingitinatwodimensionalspace.Orwecansaythat
thespaceinwhichwearerepresentingthissignalistwodimensional.Thatswhyitlookslike
atwodimensionalsignal.
Perhaps you can understand the concept of one dimension more better by looking at the
figurebelow.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

24/179

10/26/2016

DIPQuickGuide

Nowreferbacktoourinitialdiscussionondimension,Considertheabovefigurearealline
withpositivenumbersfromonepointtotheother.Nowifwehavetoexplainthelocationof
anypointonthisline,wejustneedonlyonenumber,whichmeansonlyonedimension.

2dimensionssignal
The common example of a two dimensional signal is an image , which has already been
discussedabove.

As we have already seen that an image is two dimensional signal, ie: it has two
dimensions.Itcanbemathematicallyrepresentedas:
F(x,y)=Image
Where x and y are two variables. The concept of two dimension can also be explained in
termsofmathematicsas:

Nowintheabovefigure,labelthefourcornersofthesquareasA,B,CandDrespectively.If
wecall,onelinesegmentinthefigureABandtheotherCD,thenwecanseethatthese
two parallel segments join up and make a square. Each line segment corresponds to one
dimension,sothesetwolinesegmentscorrespondto2dimensions.

3dimensionsignal
Three dimensional signal as it names refers to those signals which has three dimensions.
Themostcommonexamplehasbeendiscussedinthebeginningwhichisofourworld.We
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

25/179

10/26/2016

DIPQuickGuide

live in a three dimensional world. This example has been discussed very elaborately.
Anotherexampleofathreedimensionalsignalisacubeoravolumetricdataorthemost
commonexamplewouldbeanimatedor3dcartooncharacter.
Themathematicalrepresentationofthreedimensionalsignalis:
F(x,y,z)=animatedcharacter.
AnotheraxisordimensionZisinvolvedinathreedimension,thatgivestheillusionofdepth.
InaCartesiancoordinatesystemitcanbeviewedas:

4dimensionsignal
Inafourdimensionalsignal,fourdimensionsareinvolved.Thefirstthreearethesameas
ofthreedimensionalsignalwhichare:(X,Y,Z),andthefourthonewhichisaddedtothem
is T(time). Time is often referred to as temporal dimension which is a way to measure
change.Mathematicallyafourdsignalcanbestatedas:
F(x,y,z,t)=animatedmovie.
The common example of a 4 dimensional signal can be an animated 3d movie. As each
characterisa3dcharacterandthentheyaremovedwithrespecttothetime,duetowhich
wesawanillusionofathreedimensionalmoviemorelikearealworld.
Sothatmeansthatinrealitytheanimatedmoviesare4dimensionalie:movementof3d
charactersoverthefourthdimensiontime.

ImageFormationonCamera
Howhumaneyeworks?
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

26/179

10/26/2016

DIPQuickGuide

Before we discuss , the image formation on analog and digital cameras , we have to first
discusstheimageformationonhumaneye.Becausethebasicprinciplethatisfollowedby
thecamerashasbeentakenfromtheway,thehumaneyeworks.
When light falls upon the particular object , it is reflected back after striking through the
object.Theraysoflightwhenpassedthroughthelensofeye,formaparticularangle,and
the image is formed on the retina which is the back side of the wall. The image that is
formedisinverted.Thisimageistheninterpretedbythebrainandthatmakesusableto
understandthings.Duetoangleformation,weareabletoperceivetheheightanddepthof
the object we are seeing. This has been more explained in the tutorial of perspective
transformation.

Asyoucanseeintheabovefigure,thatwhensunlightfallsontheobject(inthiscasethe
objectisaface),itisreflectedbackanddifferentraysformdifferentanglewhentheyare
passed through the lens and an invert image of the object has been formed on the back
wall.Thelastportionofthefiguredenotesthattheobjecthasbeeninterpretedbythebrain
andreinverted.
Nowletstakeourdiscussionbacktotheimageformationonanaloganddigitalcameras.

Imageformationonanalogcameras

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

27/179

10/26/2016

DIPQuickGuide

Inanalogcameras,theimageformationisduetothechemicalreactionthattakesplaceon
thestripthatisusedforimageformation.
A35mmstripisusedinanalogcamera.Itisdenotedinthefigureby35mmfilmcartridge.
Thisstripiscoatedwithsilverhalide(achemicalsubstance).

A35mmstripisusedinanalogcamera.Itisdenotedinthefigureby35mmfilmcartridge.
Thisstripiscoatedwithsilverhalide(achemicalsubstance).
Lightisnothingbutjustthesmallparticlesknownasphotonparticles.Sowhenthesephoton
particlesarepassedthroughthecamera,itreactswiththesilverhalideparticlesonthestrip
anditresultsinthesilverwhichisthenegativeoftheimage.
Inordertounderstanditbetter,havealookatthisequation.
Photons(lightparticles)+silverhalide?silver?imagenegative.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

28/179

10/26/2016

DIPQuickGuide

This is just the basics, although image formation involves many other concepts regarding
thepassingoflightinside,andtheconceptsofshutterandshutterspeedandapertureand
itsopeningbutfornowwewillmoveontothenextpart.Althoughmostoftheseconcepts
havebeendiscussedinourtutorialofshutterandaperture.
This is just the basics, although image formation involves many other concepts regarding
thepassingoflightinside,andtheconceptsofshutterandshutterspeedandapertureand
itsopeningbutfornowwewillmoveontothenextpart.Althoughmostoftheseconcepts
havebeendiscussedinourtutorialofshutterandaperture.

Imageformationondigitalcameras
Inthedigitalcameras,theimageformationisnotduetothechemicalreactionthattake
place , rather it is a bit more complex then this. In the digital camera , a CCD array of
sensorsisusedfortheimageformation.

ImageformationthroughCCDarray

CCD stands for chargecoupled device. It is an image sensor, and like other sensors it
senses the values and converts them into an electric signal. In case of CCD it senses the
imageandconvertitintoelectricsignale.t.c.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

29/179

10/26/2016

DIPQuickGuide

ThisCCDisactuallyintheshapeofarrayorarectangulargrid.Itislikeamatrixwitheach
cellinthematrixcontainsacensorthatsensestheintensityofphoton.

Like analog cameras , in the case of digital too , when light falls on the object , the light
reflectsbackafterstrikingtheobjectandallowedtoenterinsidethecamera.
EachsensoroftheCCDarrayitselfisananalogsensor.Whenphotonsoflightstrikeonthe
chip , it is held as a small electrical charge in each photo sensor. The response of each
sensorisdirectlyequaltotheamountoflightor(photon)energystrikedonthesurfaceof
thesensor.
Since we have already define an image as a two dimensional signal and due to the two
dimensionalformationoftheCCDarray,acompleteimagecanbeachievedfromthisCCD
array.
Ithaslimitednumberofsensors,anditmeansalimiteddetailcanbecapturedbyit.Also
eachsensorcanhaveonlyonevalueagainsttheeachphotonparticlethatstrikeonit.
So the number of photons striking(current) are counted and stored. In order to measure
accuratelythese,externalCMOSsensorsarealsoattachedwithCCDarray.

Introductiontopixel
ThevalueofeachsensoroftheCCDarrayreferstoeachthevalueoftheindividualpixel.
Thenumberofsensors=numberofpixels.Italsomeansthateachsensorcouldhaveonly
oneandonlyonevalue.

Storingimage
ThechargesstoredbytheCCDarrayareconvertedtovoltageonepixelatatime.Withthe
helpofadditionalcircuits,thisvoltageisconvertedintoadigitalinformationandthenitis
stored.
Eachcompanythatmanufacturesdigitalcamera,maketheirownCCDsensors.Thatinclude
,Sony,Mistubishi,Nikon,Samsung,Toshiba,FujiFilm,Canone.t.c.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

30/179

10/26/2016

DIPQuickGuide

Apartfromtheotherfactors,thequalityoftheimagecapturedalsodependsonthetype
andqualityoftheCCDarraythathasbeenused.

CameraMechansim
Inthistutorial,wewilldiscusssomeofthebasiccameraconcepts,likeaperture,shutter,
shutter speed , ISO and we will discuss the collective use of these concepts to capture a
goodimage.

Aperture
Apertureisasmallopeningwhichallowsthelighttotravelinsideintocamera.Hereisthe
pictureofaperture.

You will see some small blades like stuff inside the aperture. These blades create a
octagonalshapethatcanbeopenedclosed.Andthusitmakesensethat,themoreblades
willopen,theholefromwhichthelightwouldhavetopasswouldbebigger.Thebiggerthe
hole,themorelightisallowedtoenter.

Effect
The effect of the aperture directly corresponds to brightness and darkness of an image. If
theapertureopeningiswide,itwouldallowmorelighttopassintothecamera.Morelight
wouldresultinmorephotons,whichultimatelyresultinabrighterimage.
Theexampleofthisisshownbelow

Considerthesetwophotos

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

31/179

10/26/2016

DIPQuickGuide

Theoneontherightsidelooksbrighter,itmeansthatwhenitwascapturedbythecamera,
theaperturewaswideopen.Ascomparetotheotherpictureontheleftside,whichisvery
dark as compare to the first one, that shows that when that image was captured, its
aperturewasnotwideopen.

Size
Nowletsdiscussthemathsbehindtheaperture.Thesizeoftheapertureisdenotedbyaf
value.Anditisinverselyproportionaltotheopeningofaperture.
Herearethetwoequations,thatbestexplainthisconcept.
Largeaperturesize=Smallfvalue
Smallaperturesize=Greaterfvalue
Pictoriallyitcanberepresentedas:

Shutter
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

32/179

10/26/2016

DIPQuickGuide

After the aperture , there comes the shutter. The light when allowed to pass from the
aperture,fallsdirectlyontotheshutter.Shutterisactuallyacover,aclosedwindow,or
can be thought of as a curtain. Remember when we talk about the CCD array sensor on
whichtheimageisformed.Wellbehindtheshutteristhesensor.Soshutteristheonlything
thatisbetweentheimageformationandthelight,whenitispassedfromaperture.
Assoonastheshutterisopen,lightfallsontheimagesensor,andtheimageisformedon
thearray.

Effect
If the shutter allows light to pass a bit longer , the image would be brighter. Similarly a
darkerpictureisproduced,whenashutterisallowedtomoveveryquicklyandhence,the
light that is allowed to pass has very less photons , and the image that is formed on the
CCDarraysensorisverydark.
Shutterhasfurthertwomainconcepts:
ShutterSpeed
Shuttertime

Shutterspeed
Theshutterspeedcanbereferredtoasthenumberoftimestheshuttergetopenorclose.
Rememberwearenottalkingaboutforhowlongtheshuttergetopenorclose.

Shuttertime
Theshuttertimecanbedefinedas
When the shutter is open , then the amount of wait time it take till it is closed is called
shuttertime.
Inthiscasewearenottalkingabouthowmanytimes,theshuttergotopenorclose,but
wearetalkingaboutforhowmuchtimedoesitremainwideopen.
Forexample:
Wecanbetterunderstandthesetwoconceptsinthisway.Thatletssaythatashutteropens
15timesandthengetclosed,andforeachtimeitopensfor1secondandthengetclosed.
Inthisexample,15istheshutterspeedand1secondistheshuttertime.

Relationship
The relationship between shutter speed and shutter time is that they are both inversely
proportionaltoeachother.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

33/179

10/26/2016

DIPQuickGuide

Thisrelationshipcanbedefinedintheequationbelow.
Moreshutterspeed=lessshuttertime
Lessshutterspeed=moreshuttertime.

Explanation:
Thelesserthetimerequired,themoreisthespeed.Andthegreaterthetimerequired,the
lessisthespeed.

Applications
Thesetwoconceptstogethermakeavarietyofapplications.Someofthemaregivenbelow.

Fastmovingobjects:
Ifyouweretocapturetheimageofafastmovingobject,couldbeacaroranything.The
adjustmentofshutterspeedanditstimewouldeffectalot.
So,inordertocaptureanimagelikethis,wewillmaketwoamendments:
Increaseshutterspeed
Decreaseshuttertime
Whathappensis,thatwhenweincreaseshutterspeed,themorenumberoftimes,the
shutterwouldopenorclose.Itmeansdifferentsamplesoflightwouldallowtopassin.And
when we decrease shutter time , it means we will immediately captures the scene, and
closetheshuttergate.
Ifyouwilldothis,yougetacrispimageofafastmovingobject.
In order to understand it , we will look at this example. Suppose you want to capture the
imageoffastmovingwaterfall.
Yousetyourshutterspeedto1secondandyoucaptureaphoto.Thisiswhatyouget

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

34/179

10/26/2016

DIPQuickGuide

Thenyousetyourshutterspeedtoafasterspeedandyouget.

Thenagainyousetyourshutterspeedtoevenmorefasterandyouget.

Youcanseeinthelastpicture,thatwehaveincreaseourshutterspeedtoveryfast,that
means that a shutter get opened or closed in 200th of 1 second and so we got a crisp
image.

ISO
ISO factor is measured in numbers. It denotes the sensitivity of light to camera. If ISO
numberislowered,itmeansourcameraislesssensitivetolightandiftheISOnumberis
high,itmeansitismoresenstivie.

Effect
ThehigheristheISO,themorebrighterthepicturewouldbe.IFISOissetto1600,the
picturewouldbeverybrighterandviceversa.

Sideeffect
If the ISO increases, the noise in the image also increases. Today most of the camera
manufacturingcompaniesareworkingonremovingthenoisefromtheimagewhenISOis
settohigherspeed.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

ConceptofPixel

35/179

10/26/2016

DIPQuickGuide

ConceptofPixel
Pixel
Pixelisthesmallestelementofanimage.Eachpixelcorrespondtoanyonevalue.Inan8
bitgrayscaleimage,thevalueofthepixelbetween0and255.Thevalueofapixelatany
pointcorrespondtotheintensityofthelightphotonsstrikingatthatpoint.Eachpixelstorea
valueproportionaltothelightintensityatthatparticularlocation.

PEL
A pixel is also known as PEL. You can have more understanding of the pixel from the
picturesgivenbelow.
Intheabovepicture,theremaybethousandsofpixels,thattogethermakeupthisimage.
We will zoom that image to the extent that we are able to see some pixels division. It is
shownintheimagebelow.

Intheabovepicture,theremaybethousandsofpixels,thattogethermakeupthisimage.
We will zoom that image to the extent that we are able to see some pixels division. It is
shownintheimagebelow.

RelationshipwithCCDarray
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

36/179

10/26/2016

DIPQuickGuide

WehaveseenthathowanimageisformedintheCCDarray.Soapixelcanalsobedefined
as
ThesmallestdivisiontheCCDarrayisalsoknownaspixel.
EachdivisionofCCDarraycontainsthevalueagainsttheintensityofthephotonstrikingto
it.Thisvaluecanalsobecalledasapixel

Calculationoftotalnumberofpixels
We have define an image as a two dimensional signal or matrix. Then in that case the
numberofPELwouldbeequaltothenumberofrowsmultiplywithnumberofcolumns.
Thiscanbemathematicallyrepresentedasbelow:
Totalnumberofpixels=numberofrows(X)numberofcolumns
Orwecansaythatthenumberof(x,y)coordinatepairsmakeupthetotalnumberofpixels.
We will look in more detail in the tutorial of image types , that how do we calculate the
pixelsinacolorimage.

Graylevel
Thevalueofthepixelatanypointdenotestheintensityofimageatthatlocation,andthat
isalsoknownasgraylevel.
Wewillseeinmoredetailaboutthevalueofthepixelsintheimagestorageandbitsper
pixeltutorial,butfornowwewilljustlookattheconceptofonlyonepixelvalue.

Pixelvalue.(0)
Asithasalreadybeendefineinthebeginningofthistutorial,thateachpixelcanhaveonly
onevalueandeachvaluedenotestheintensityoflightatthatpointoftheimage.
Wewillnowlookataveryuniquevalue0.Thevalue0meansabsenceoflight.Itmeans
that0denotesdark,anditfurthermeansthatwheneverapixelhasavalueof0,itmeans
atthatpoint,blackcolorwouldbeformed.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

37/179

10/26/2016

DIPQuickGuide

Havealookatthisimagematrix
0

Nowthisimagematrixhasallfilledupwith0.Allthepixelshaveavalueof0.Ifwewereto
calculatethetotalnumberofpixelsformthismatrix,thisishowwearegoingtodoit.
Totalnoofpixels=totalno.ofrowsXtotalno.ofcolumns
=3X3
=9.
It means that an image would be formed with 9 pixels, and that image would have a
dimensionof3rowsand3columnandmostimportantlythatimagewouldbeblack.
Theresultingimagethatwouldbemadewouldbesomethinglikethis

Nowwhyisthisimageallblack.Becauseallthepixelsintheimagehadavalueof0.

PerspectiveTransformation
Whenhumaneyesseenearthingstheylookbiggerascomparetothosewhoarefaraway.
This is called perspective in a general way. Whereas transformation is the transfer of an
objecte.t.cfromonestatetoanother.
So overall , the perspective transformation deals with the conversion of 3d world into 2d
image. The same principle on which human vision works and the same principle on which
thecameraworks.
Wewillseeindetailaboutwhythishappens,thatthoseobjectswhichareneartoyoulook
bigger,whilethosewhoarefaraway,looksmallereventhoughtheylookbiggerwhenyou
reachthem.
Wewillstartthisdiscussionbytheconceptofframeofreference:

Frameofreference:
Frameofreferenceisbasicallyasetofvaluesinrelationtowhichwemeasuresomething.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

38/179

10/26/2016

DIPQuickGuide

5framesofreference
Inordertoanalyzea3dworld/image/scene,5differentframeofreferencesarerequired.
Object
World
Camera
Image
Pixel

Objectcoordinateframe
Objectcoordinateframeisusedformodelingobjects.Forexample,checkingifaparticular
objectisinaproperplacewithrespecttotheotherobject.Itisa3dcoordinatesystem.

Worldcoordinateframe
Worldcoordinateframeisusedforcorelatingobjectsina3dimensionalworld.Itisa3d
coordinatesystem.

Cameracoordinateframe
Cameracoordinateframeisusedtorelateobjectswithrespectofthecamera.Itisa3d
coordinatesystem.

Imagecoordinateframe
It is not a 3d coordinate system , rather it is a 2d system. It is used to describe how 3d
pointsaremappedina2dimageplane.

Pixelcoordinateframe
Itisalsoa2dcoordinatesystem.Eachpixelhasavalueofpixelcoordinates.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

39/179

10/26/2016

DIPQuickGuide

Transformationbetweenthese5frames

Thatshowa3dsceneistransformedinto2d,withimageofpixels.
Nowwewillexplainthisconceptmathematically.

Where

Y=3dobject
y=2dImage
f=focallengthofthecamera
Z=distancebetweenimageandthecamera
NowtherearetwodifferentanglesformedinthistransformwhicharerepresentedbyQ.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

40/179

10/26/2016

DIPQuickGuide

Thefirstangleis

Whereminusdenotesthatimageisinverted.Thesecondanglethatisformedis:

Comparingthesetwoequationsweget

Fromthisequation,wecanseethatwhentheraysoflightreflectbackafterstrikingfrom
theobject,passedfromthecamera,aninvertimageisformed.
Wecanbetterunderstandthis,withthisexample.
Forexample

Calculatingthesizeofimageformed
Supposeanimagehasbeentakenofaperson5mtall,andstandingatadistanceof50m
fromthecamera,andwehavetotellthatwhatisthesizeoftheimageoftheperson,with
acameraoffocallengthis50mm.

Solution:
Sincethefocallengthisinmillimeter,sowehavetoconverteverythinginmillimeterin
ordertocalculateit.
So,
Y=5000mm.
f=50mm.
Z=50000mm.
Puttingthevaluesintheformula,weget

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

41/179

10/26/2016

DIPQuickGuide

=5mm.
Again,theminussignindicatesthattheimageisinverted.

ConceptofBitsPerPixel
Bpporbitsperpixeldenotesthenumberofbitsperpixel.Thenumberofdifferentcolorsin
animageisdependsonthedepthofcolororbitsperpixel.

Bitsinmathematics:
Itsjustlikeplayingwithbinarybits.
Howmanynumberscanberepresentedbyonebit.
0
1
Howmanytwobitscombinationscanbemade.
00
01
10
11
Ifwedeviseaformulaforthecalculationoftotalnumberofcombinationsthatcanbemade
frombit,itwouldbelikethis.

Wherebppdenotesbitsperpixel.Put1intheformulayouget2,put2intheformula,you
get4.Itgrowsexponentionally.

Numberofdifferentcolors:
Now as we said it in the beginning , that the number of different colors depend on the
numberofbitsperpixel.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

42/179

10/26/2016

DIPQuickGuide

Thetableforsomeofthebitsandtheircolorisgivenbelow.
Bitsperpixel

Numberofcolors

1bpp

2colors

2bpp

4colors

3bpp

8colors

4bpp

16colors

5bpp

32colors

6bpp

64colors

7bpp

128colors

8bpp

256colors

10bpp

1024colors

16bpp

65536colors

24bpp

16777216colors(16.7millioncolors)

32bpp

4294967296colors(4294millioncolors)

Thistableshowsdifferentbitsperpixelandtheamountofcolortheycontain.

Shades
Youcaneasilynoticethepatternoftheexponentionalgrowth.Thefamousgrayscaleimage
isof8bpp,meansithas256differentcolorsinitor256shades.
Shadescanberepresentedas:

Colorimagesareusuallyofthe24bppformat,or16bpp.
Wewillseemoreaboutothercolorformatsandimagetypesinthetutorialofimagetypes.

Colorvalues:
Wehavepreviouslyseeninthetutorialofconceptofpixel,that0pixelvaluedenotesblackcolor.

Blackcolor:
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

43/179

10/26/2016

DIPQuickGuide

Remember,0pixelvaluealwaysdenotesblackcolor.Butthereisnofixedvaluethatdenotes
whitecolor.

Whitecolor:
Thevaluethatdenoteswhitecolorcanbecalculatedas:

Incaseof1bpp,0denotesblack,and1denoteswhite.
Incase8bpp,0denotesblack,and255denoteswhite.

Graycolor:
Whenyoucalculatetheblackandwhitecolorvalue,thenyoucancalculatethepixelvalue
ofgraycolor.
Graycolorisactuallythemidpointofblackandwhite.Thatsaid,
Incaseof8bpp,thepixelvaluethatdenotesgraycoloris127or128bpp(ifyoucountfrom
1,notfrom0).

Imagestoragerequirements
Afterthediscussionofbitsperpixel,nowwehaveeverythingthatweneedtocalculatea
sizeofanimage.

Imagesize
Thesizeofanimagedependsuponthreethings.
Numberofrows
Numberofcolumns
Numberofbitsperpixel
Theformulaforcalculatingthesizeisgivenbelow.
Sizeofanimage=rows*cols*bpp
Itmeansthatifyouhaveanimage,letssaythisone:

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

44/179

10/26/2016

DIPQuickGuide

Assumingithas1024rowsandithas1024columns.Andsinceitisagrayscaleimage,it
has 256 different shades of gray or it has bits per pixel. Then putting these values in the
formula,weget
Sizeofanimage=rows*cols*bpp
=1024*1024*8
=8388608bits.
Butsinceitsnotastandardanswerthatwerecognize,sowillconvertitintoourformat.
Convertingitintobytes=8388608/8=1048576bytes.
Convertingintokilobytes=1048576/1024=1024kb.
ConvertingintoMegabytes=1024/1024=1Mb.
Thatshowanimagesizeiscalculatedanditisstored.Nowintheformula,ifyouaregiven
thesizeofimageandthebitsperpixel,youcanalsocalculatetherowsandcolumnsofthe
image,providedtheimageissquare(samerowsandsamecolumn).

TypesofImages
Therearemanytypeofimages,andwewilllookindetailaboutdifferenttypesofimages,
andthecolordistributioninthem.

Thebinaryimage
Thebinaryimageasitnamestates,containonlytwopixelvalues.
0and1.
In our previous tutorial of bits per pixel , we have explained this in detail about the
representationofpixelvaluestotheirrespectivecolors.
Here0referstoblackcolorand1referstowhitecolor.ItisalsoknownasMonochrome.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

45/179

10/26/2016

DIPQuickGuide

Blackandwhiteimage:
Theresultingimagethatisformedhenceconsistofonlyblackandwhitecolorandthuscan
alsobecalledasBlackandWhiteimage.

Nograylevel
Oneoftheinterestingthisaboutthisbinaryimagethatthereisnograylevelinit.Onlytwo
colorsthatareblackandwhitearefoundinit.

Format
BinaryimageshaveaformatofPBM(Portablebitmap)

2,3,4,5,6bitcolorformat
Theimageswithacolorformatof2,3,4,5and6bitarenotwidelyusedtoday.Theywere
usedinoldtimesforoldTVdisplays,ormonitordisplays.
Buteachofthesecolorshavemorethentwograylevels,andhencehasgraycolorunlike
thebinaryimage.
In a 2 bit 4, in a 3 bit 8 , in a 4 bit 16, in a 5 bit 32, in a 6 bit 64 different colors are
present.

8bitcolorformat
8bitcolorformatisoneofthemostfamousimageformat.Ithas256differentshadesof
colorsinit.ItiscommonlyknownasGrayscaleimage.
Therangeofthecolorsin8bitvaryfrom0255.Where0standsforblack,and255stands
forwhite,and127standsforgraycolor.
ThisformatwasusedinitiallybyearlymodelsoftheoperatingsystemsUNIXandtheearly
colorMacintoshes.
AgrayscaleimageofEinsteinisshownbelow:

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

46/179

10/26/2016

DIPQuickGuide

Format
TheformatoftheseimagesarePGM(PortableGrayMap).
Thisformatisnotsupportedbydefaultfromwindows.Inordertoseegrayscaleimage,you
needtohaveanimageviewerorimageprocessingtoolboxsuchasMatlab.

Behindgrayscaleimage:
Aswehaveexplaineditseveraltimesintheprevioustutorials,thatanimageisnothingbut
atwodimensionalfunction,andcanberepresentedbyatwodimensionalarrayormatrix.
So in the case of the image of Einstein shown above , there would be two dimensional
matrixinbehindwithvaluesrangingbetween0and255.
Butthatsnotthecasewiththecolorimages.

16bitcolorformat
Itisacolorimageformat.Ithas65,536differentcolorsinit.ItisalsoknownasHighcolor
format.
IthasbeenusedbyMicrosoftintheirsystemsthatsupportmorethen8bitcolorformat.
Now in this 16 bit format and the next format we are going to discuss which is a 24 bit
formatarebothcolorformat.
Thedistributionofcolorinacolorimageisnotassimpleasitwasingrayscaleimage.
A16bitformatisactuallydividedintothreefurtherformatswhichareRed,GreenandBlue.
Thefamous(RGB)format.
Itispictoriallyrepresentedintheimagebelow.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

47/179

10/26/2016

DIPQuickGuide

Nowthequestionarises,thathowwouldyoudistribute16intothree.Ifyoudoitlikethis,
5bitsforR,5bitsforG,5bitsforB
Thenthereisonebitremainsintheend.
Sothedistributionof16bithasbeendonelikethis.
5bitsforR,6bitsforG,5bitsforB.
Theadditionalbitthatwasleftbehindisaddedintothegreenbit.Becausegreenisthecolor
whichismostsoothingtoeyesinallofthesethreecolors.
Notethisisdistributionisnotfollowedbyallthesystems.Somehaveintroducedanalpha
channelinthe16bit.

Anotherdistributionof16bitformatislikethis:
4bitsforR,4bitsforG,4bitsforB,4bitsforalphachannel.
Orsomedistributeitlikethis
5bitsforR,5bitsforG,5bitsforB,1bitsforalphachannel.

24bitcolorformat
24 bit color format also known as true color format. Like 16 bit color format , in a 24 bit
colorformat,the24bitsareagaindistributedinthreedifferentformatsofRed,Greenand
Blue.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

48/179

10/26/2016

DIPQuickGuide

Since24isequallydividedon8,soithasbeendistributedequallybetweenthreedifferent
colorchannels.
Theirdistributionislikethis.
8bitsforR,8bitsforG,8bitsforB.

Behinda24bitimage.
Unlikea8bitgrayscaleimage,whichhasonematrixbehindit,a24bitimagehasthree
differentmatricesofR,G,B.

Format
Itisthemostcommonusedformat.ItsformatisPPM(PortablepixMap)whichissupported
by Linux operating system. The famous windows has its own format for it which is BMP (
Bitmap).

ColorCodesConversion
Inthistutorial,wewillseethathowdifferentcolorcodescanbecombinedtomakeother
colors,andhowwecancovertRGBcolorcodestohexandviceversa.

Differentcolorcodes
Allthecolorshereareofthe24bitformat,thatmeanseachcolorhas8bitsofred,8bits
ofgreen,8bitsofblue,init.Orwecansayeachcolorhasthreedifferentportions.Youjust
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

49/179

10/26/2016

DIPQuickGuide

havetochangethequantityofthesethreeportionstomakeanycolor.

Binarycolorformat
Color:Black
Image:
DecimalCode:
(0,0,0)

Explanation:
Asithasbeenexplainedintheprevioustutorials,thatinan8bitformat,0referstoblack.
Soifwehavetomakeapureblackcolor,wehavetomakeallthethreeportionofR,G,B
to0.

Color:White
Image:
DecimalCode:
(255,255,255)

Explanation:
SinceeachportionofR,G,Bisan8bitportion.Soin8bit,thewhitecolorisformedby255.
Itisexplainedinthetutorialofpixel.Soinordertomakeawhitecolorweseteachportion
to 255 and thats how we got a white color. By setting each of the value to 255 , we get
overallvalueof255,thatsmakethecolorwhite.

RGBcolormodel:
Color:Red
Image:
DecimalCode:
(255,0,0)

Explanation:
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

50/179

10/26/2016

DIPQuickGuide

Sinceweneedonlyredcolor,sowezeroouttherestofthetwoportionswhicharegreen
andblue,andwesettheredportiontoitsmaximumwhichis255.

Color:Green
Image:
DecimalCode:
(0,255,0)

Explanation:
Sinceweneedonlygreencolor,sowezeroouttherestofthetwoportionswhicharered
andblue,andwesetthegreenportiontoitsmaximumwhichis255.

Color:Blue
Image:
DecimalCode:
(0,0,255)

Explanation:
Sinceweneedonlybluecolor,sowezeroouttherestofthetwoportionswhichareredand
green,andwesettheblueportiontoitsmaximumwhichis255

Graycolor:
Color:Gray
Image:
DecimalCode:
(128,128,128)

Explanation:
Aswehavealreadydefinedinourtutorialofpixel,thatgraycolorIsactuallythemidpoint.
In an 8bit format , the mid point is 128 or 127. In this case we choose 128. So we set
eachoftheportiontoitsmidpointwhichis128,andthatresultsinoverallmidvalueand
wegotgraycolor.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

51/179

10/26/2016

DIPQuickGuide

CMYKcolormodel:
CMYKisanothercolormodelwherecstandsforcyan,mstandsformagenta,ystandsfor
yellow,andkforblack.CMYKmodeliscommonlyusedincolorprintersinwhichthereare
twocartersofcolorisused.OneconsistofCMYandotherconsistofblackcolor.
ThecolorsofCMYcanalsomadefromchangingthequantityorportionofred,greenand
blue.

Color:Cyan
Image:
DecimalCode:
(0,255,255)

Explanation:
CyancolorisformedfromthecombinationoftwodifferentcolorswhichareGreenandblue.
Sowesetthosetwotomaximumandwezeroouttheportionofred.Andwegetcyancolor.

Color:Magenta
Image:
DecimalCode:
(255,0,255)

Explanation:
Magenta color is formed from the combination of two different colors which are Red and
Blue.Sowesetthosetwotomaximumandwezeroouttheportionofgreen.Andweget
magentacolor.

Color:Yellow
Image:
DecimalCode:
(255,255,0)

Explanation:
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

52/179

10/26/2016

DIPQuickGuide

YellowcolorisformedfromthecombinationoftwodifferentcolorswhichareRedandGreen.
Sowesetthosetwotomaximumandwezeroouttheportionofblue.Andwegetyellow
color.

Conversion
Nowwewillseethathowcolorareconvertedarefromoneformattoanother.

ConversionfromRGBtoHexcode:
ConversionfromHextorgbisdonethroughthismethod:
Takeacolor.E.g:White=(255,255,255).
Takethefirstportione.g255.
Divideitby16.Likethis:

Takethetwonumbersbelowline,thefactor,andtheremainder.Inthiscaseitis
1515whichisFF.
Repeatthestep2forthenexttwoportions.
Combineallthehexcodeintoone.
Answer:#FFFFFF

ConversionfromHextoRGB:
Conversionfromhexcodetorgbdecimalformatisdoneinthisway.
Takeahexnumber.E.g:#FFFFFF
Breakthisnumberinto3parts:FFFFFF
Takethefirstpartandseparateitscomponents:FF
Converteachofthepartseparatelyintobinary:(1111)(1111)
Nowcombinetheindividualbinariesintoone:11111111
Convertthisbinaryintodecimal:255
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

53/179

10/26/2016

DIPQuickGuide

Nowrepeatstep2,twomoretimes.
ThevaluecomesinthefirststepisR,secondoneisG,andthethirdonebelongstoB.
Answer:(255,255,255)

CommoncolorsandtheirHexcodehasbeengivenin
thistable.
Color

HexCode

Black

#000000

White

#FFFFFF

Gray

#808080

Red

#FF0000

Green

#00FF00

Blue

#0000FF

Cyan

#00FFFF

Magenta

#FF00FF

Yellow

#FFFF00

GrayscaeltoRGBConversion
WehavealreadydefinetheRGBcolormodelandgrayscaleformatinourtutorialofImagetypes.
Nowwewillconvertancolorimageintoagrayscaleimage.Therearetwomethodstoconvertit.
Bothhastheirownmeritsanddemerits.Themethodsare:

Averagemethod
Weightedmethodorluminositymethod

Averagemethod
Averagemethodisthemostsimpleone.Youjusthavetotaketheaverageofthreecolors.
SinceitsanRGBimage,soitmeansthatyouhaveaddrwithgwithbandthendivideitby
3togetyourdesiredgrayscaleimage.
Itsdoneinthisway.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

54/179

10/26/2016

DIPQuickGuide

Grayscale=(R+G+B/3)
Forexample:

If you have an color image like the image shown above and you want to convert it into
grayscaleusingaveragemethod.Thefollowingresultwouldappear.

Explanation
Thereisonethingtobesure,thatsomethinghappenstotheoriginalworks.Itmeansthat
ouraveragemethodworks.Buttheresultswerenotasexpected.Wewantedtoconvertthe
imageintoagrayscale,butthisturnedouttobearatherblackimage.

Problem
Thisproblemariseduetothefact,thatwetakeaverageofthethreecolors.Sincethethree
different colors have three different wavelength and have their own contribution in the
formationofimage,sowehavetotakeaverageaccordingtotheircontribution,notdoneit
averagelyusingaveragemethod.Rightnowwhatwearedoingisthis,
33%ofRed,33%ofGreen,33%ofBlue
Wearetaking33%ofeach,thatmeans,eachoftheportionhassamecontributioninthe
image.Butinrealitythatsnotthecase.Thesolutiontothishasbeengivenbyluminosity
method.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

55/179

10/26/2016

DIPQuickGuide

Weightedmethodorluminositymethod
You have seen the problem that occur in the average method. Weighted method has a
solutiontothatproblem.Sinceredcolorhasmorewavelengthofallthethreecolors,and
greenisthecolorthathasnotonlylesswavelengththenredcolorbutalsogreenisthecolor
thatgivesmoresoothingeffecttotheeyes.
It means that we have to decrease the contribution of red color , and increase the
contributionofthegreencolor,andputbluecolorcontributioninbetweenthesetwo.
Sothenewequationthatformis:
Newgrayscaleimage=((0.3*R)+(0.59*G)+(0.11*B)).
Accordingtothisequation,Redhascontribute30%,Greenhascontributed59%whichis
greaterinallthreecolorsandBluehascontributed11%.
Applyingthisequationtotheimage,wegetthis
OriginalImage:

GrayscaleImage:

Explanation
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

56/179

10/26/2016

DIPQuickGuide

Asyoucanseehere,thattheimagehasnowbeenproperlyconvertedtograyscaleusing
weightedmethod.Ascomparetotheresultofaveragemethod,thisimageismorebrighter.

ConceptofSampling
Conversionofanalogsignaltodigitalsignal:
Theoutputofmostoftheimagesensorsisananalogsignal,andwecannotapplydigital
processingonitbecausewecannotstoreit.Wecannotstoreitbecauseitrequiresinfinite
memorytostoreasignalthatcanhaveinfinitevalues.
Sowehavetoconvertananalogsignalintoadigitalsignal.
To create an image which is digital , we need to covert continuous data into digital form.
Therearetwostepsinwhichitisdone.
Sampling
Quantization
Wewilldiscusssamplingnow,andquantizationwillbediscussedlateronbutfornowonwe
willdiscussjustalittleaboutthedifferencebetweenthesetwoandtheneedofthesetwo
steps.

Basicidea:
Thebasicideabehindconvertingananalogsignaltoitsdigitalsignalis

toconvertbothofitsaxis(x,y)intoadigitalformat.
Sinceanimageiscontinuousnotjustinitscoordinates(xaxis),butalsoinitsamplitude
(yaxis),sothepartthatdealswiththedigitizingofcoordinatesisknownassampling.And
thepartthatdealswithdigitizingtheamplitudeisknownasquantization.

Sampling.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

57/179

10/26/2016

DIPQuickGuide

Samplinghasalreadybeenintroducedinourtutorialofintroductiontosignalsandsystem.
Butwearegoingtodiscussheremore.
Herewhatwehavediscussedofthesampling.
Thetermsamplingreferstotakesamples
Wedigitizexaxisinsampling
Itisdoneonindependentvariable
Incaseofequationy=sin(x),itisdoneonxvariable
Itisfurtherdividedintotwoparts,upsamplinganddownsampling

Ifyouwilllookattheabovefigure,youwillseethattherearesomerandomvariationsin
the signal. These variations are due to noise. In sampling we reduce this noise by taking
samples.Itisobviousthatmoresampleswetake,thequalityoftheimagewouldbemore
better,thenoisewouldbemoreremovedandsamehappensviceversa.
However,ifyoutakesamplingonthexaxis,thesignalisnotconvertedtodigitalformat,
unless you take sampling of the yaxis too which is known as quantization. The more
samples eventually means you are collecting more data, and in case of image , it means
morepixels.

Relationshipwithpixels
Sinceapixelisasmallestelementinanimage.Thetotalnumberofpixelsinanimagecan
becalculatedas
Pixels=totalnoofrows*totalnoofcolumns.
Letssaywehavetotalof25pixels,thatmeanswehaveasquareimageof5X5.Thenas
wehavedicussedaboveinsampling,thatmoresampleseventuallyresultinmorepixels.
Soitmeansthatofourcontinuoussignal,wehavetaken25samplesonxaxis.Thatrefers
to25pixelsofthisimage.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

58/179

10/26/2016

DIPQuickGuide

ThisleadstoanotherconclusionthatsincepixelisalsothesmallestdivisionofaCCDarray.
SoitmeansithasarelationshipwithCCDarraytoo,whichcanbeexplainedasthis.

RelationshipwithCCDarray
ThenumberofsensorsonaCCDarrayisdirectlyequaltothenumberofpixels.Andsince
we have concluded that the number of pixels is directly equal to the number of samples,
thatmeansthatnumbersampleisdirectlyequaltothenumberofsensorsonCCDarray.

Oversampling.
Inthebeginningwehavedefinethatsamplingisfurthercategorizeintotwotypes.Whichis
upsamplinganddownsampling.Upsamplingisalsocalledasoversampling.
The oversampling has a very deep application in image processing which is known as
Zooming.

Zooming
Wewillformallyintroducezoomingintheupcomingtutorial,butfornowon,wewilljust
brieflyexplainzooming.
Zoomingreferstoincreasethequantityofpixels,sothatwhenyouzoomanimage,you
willseemoredetail.
Theincreaseinthequantityofpixelsisdonethroughoversampling.Theonewaytozoomis
,ortoincreasesamples,istozoomoptically,throughthemotormovementofthelensand
thencapturetheimage.Butwehavetodoit,oncetheimagehasbeencaptured.

Thereisadifferencebetweenzoomingandsampling.
The concept is same , which is, to increase samples. But the key difference is that while
samplingisdoneonthesignals,zoomingisdoneonthedigitalimage.

PixelResolution
Beforewedefinepixelresolution,itisnecessarytodefineapixel.

Pixel
Wehavealreadydefinedapixelinourtutorialofconceptofpixel,inwhichwedefineapixel
as the smallest element of an image. We also defined that a pixel can store a value
proportionaltothelightintensityatthatparticularlocation.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

59/179

10/26/2016

DIPQuickGuide

Nowsincewehavedefinedapixel,wearegoingtodefinewhatisresolution.

Resolution
The resolution can be defined in many ways. Such as pixel resolution , spatial resolution ,
temporal resolution , spectral resolution. Out of which we are going to discuss pixel
resolution.
Youhaveprobablyseenthatinyourowncomputersettings,youhavemonitorresolutionof
800x600,640x480e.t.c
Inpixelresolution,thetermresolutionreferstothetotalnumberofcountofpixelsinan
digitalimage.Forexample.IfanimagehasMrowsandNcolumns,thenitsresolutioncan
bedefinedasMXN.
Ifwedefineresolutionasthetotalnumberofpixels,thenpixelresolutioncanbedefined
with set of two numbers. The first number the width of the picture , or the pixels across
columns,andthesecondnumberisheightofthepicture,orthepixelsacrossitswidth.
Wecansaythatthehigheristhepixelresolution,thehigheristhequalityoftheimage.
Wecandefinepixelresolutionofanimageas4500X5500.

Megapixels
Wecancalculatemegapixelsofacamerausingpixelresolution.
Columnpixels(width)Xrowpixels(height)/1Million.
Thesizeofanimagecanbedefinedbyitspixelresolution.
Size=pixelresolutionXbpp(bitsperpixel)

Calculatingthemegapixelsofthecamera
Letssaywehaveanimageofdimension:2500X3192.
Itspixelresolution=2500*3192=7982350bytes.
Dividingitby1million=7.9=8megapixel(approximately).

Aspectratio
Anotherimportantconceptwiththepixelresolutionisaspectratio.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

60/179

10/26/2016

DIPQuickGuide

Aspect ratio is the ratio between width of an image and the height of an image. It is
commonly explained as two numbers separated by a colon (8:9). This ratio differs in
differentimages,andindifferentscreens.Thecommonaspectratiosare:
1.33:1,1.37:1,1.43:1,1.50:1,1.56:1,1.66:1,1.75:1,1.78:1,1.85:1,2.00:1,e.t.c

Advantage:
Aspect ratio maintains a balance between the appearance of an image on the screen ,
meansitmaintainsaratiobetweenhorizontalandverticalpixels.Itdoesnotlettheimage
togetdistortedwhenaspectratioisincreased.

Forexample:
This is a sample image , which has 100 rows and 100 columns. If we wish to make is
smaller,andtheconditionisthatthequalityremainsthesameorinotherwaytheimage
doesnotgetdistorted,herehowithappens.

Originalimage:

ChangingtherowsandcolumnsbymaintaintheaspectratioinMSPaint.

Result

Smallerimage,butwithsamebalance.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

61/179

10/26/2016

DIPQuickGuide

Youhaveprobablyseenaspectratiosinthevideoplayers,whereyoucanadjustthevideo
accordingtoyourscreenresolution.
Findingthedimensionsoftheimagefromaspectratio:
Aspectratiotellsusmanythings.Withtheaspectratio,youcancalculatethedimensionsof
theimagealongwiththesizeoftheimage.

Forexample
Ifyouaregivenanimagewithaspectratioof6:2ofanimageofpixelresolutionof480000
pixelsgiventheimageisangrayscaleimage.
Andyouareaskedtocalculatetwothings.
Resolvepixelresolutiontocalculatethedimensionsofimage
Calculatethesizeoftheimage

Solution:
Given:
Aspectratio:c:r=6:2
Pixelresolution:c*r=480000
Bitsperpixel:grayscaleimage=8bpp

Find:
Numberofrows=?
Numberofcols=?

Solvingfirstpart:

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

62/179

10/26/2016

DIPQuickGuide

Solving2ndpart:
Size=rows*cols*bpp
Sizeofimageinbits=400*1200*8=3840000bits
Sizeofimageinbytes=480000bytes
Sizeofimageinkilobytes=48kb(approx).

ConceptofZooming
In this tutorial we are going to introduce the concept of zooming , and the common
techniquesthatareusedtozoomanimage.

Zooming
Zoomingsimplymeansenlargingapictureinasensethatthedetailsintheimagebecame
morevisibleandclear.Zoominganimagehasmanywideapplicationsrangingfromzooming
throughacameralens,tozoomanimageoninternete.t.c.

Forexample
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

63/179

10/26/2016

DIPQuickGuide

iszoomedinto

Youcanzoomsomethingattwodifferentsteps.
The first step includes zooming before taking an particular image. This is known as pre
processingzoom.Thiszoominvolveshardwareandmechanicalmovement.
The second step is to zoom once an image has been captured. It is done through many
differentalgorithmsinwhichwemanipulatepixelstozoomintherequiredportion.
Wewilldiscussthemindetailinthenexttutorial.

OpticalZoomvsdigitalZoom
Thesetwotypesofzoomaresupportedbythecameras.

OpticalZoom:
The optical zoom is achieved using the movement of the lens of your camera. An optical
zoomisactuallyatruezoom.Theresultoftheopticalzoomisfarbetterthenthatofdigital
zoom.Inopticalzoom,animageismagnifiedbythelensinsuchawaythattheobjectsin
theimageappeartobeclosertothecamera.Inopticalzoomthelensisphysicallyextend
tozoomormagnifyanobject.

DigitalZoom:

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

64/179

10/26/2016

DIPQuickGuide

Digital zoom is basically image processing within a camera. During a digital zoom , the
centeroftheimageismagnifiedandtheedgesofthepicturegotcropout.Duetomagnified
center,itlookslikethattheobjectisclosertoyou.
During a digital zoom , the pixels got expand , due to which the quality of the image is
compromised.
Thesameeffectofdigitalzoomcanbeseenaftertheimageistakenthroughyourcomputer
byusinganimageprocessingtoolbox/software,suchasPhotoshop.
Thefollowingpictureistheresultofdigitalzoomdonethroughoneofthefollowingmethods
givenbelowinthezoomingmethods.

Nowsinceweareleaningdigitalimageprocessing,wewillnotfocus,onhowanimagecan
be zoomed optically using lens or other stuff. Rather we will focus on the methods, that
enabletozoomadigitalimage.

Zoomingmethods:
Althoughtherearemanymethodsthatdoesthisjob,butwearegoingtodiscussthemost
commonofthemhere.
Theyarelistedbelow.
Pixelreplicationor(Nearestneighborinterpolation)
Zeroorderholdmethod
ZoomingKtimes
Allthesethreemethodsareformallyintroducedinthenexttutorial.

ZoomingMethods
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

65/179

ZoomingMethods

10/26/2016

DIPQuickGuide

In this tutorial we are going to formally introduce three methods of zooming that were
introducedinthetutorialofIntroductiontozooming.

Methods
Pixelreplicationor(Nearestneighborinterpolation)
Zeroorderholdmethod
ZoomingKtimes
Each of the methods have their own advantages and disadvantages. We will start by
discussingpixelreplication.

Method1:Pixelreplication:
Introduction:
ItisalsoknownasNearestneighborinterpolation.Asitsnamesuggest,inthismethod,we
just replicate the neighboring pixels. As we have already discussed in the tutorial of
Sampling,thatzoomingisnothingbutincreaseamountofsampleorpixels.Thisalgorithm
worksonthesameprinciple.

Working:
Inthismethodwecreatenewpixelsformthealreadygivenpixels.Eachpixelisreplicatedin
thismethodntimesrowwiseandcolumnwiseandyougotazoomedimage.Itsassimple
asthat.

Forexample:
ifyouhaveanimageof2rowsand2columnsandyouwanttozoomittwiceor2times
usingpixelreplication,herehowitcanbedone.
Forabetterunderstanding,theimagehasbeentakenintheformofmatrixwiththepixel
valuesoftheimage.
1

Theaboveimagehastworowsandtwocolumns,wewillfirstzoomitrowwise.

Rowwisezooming:
Whenwezoomitrowwise,wewilljustsimplecopytherowspixelstoitsadjacentnewcell.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

66/179

10/26/2016

DIPQuickGuide

Herehowitwouldbedone.
1

Asyoucanthatintheabovematrix,eachpixelisreplicatedtwiceintherows.

Columnsizezooming:
The next step is to replicate each of the pixel column wise, that we will simply copy the
columnpixeltoitsadjacentnewcolumnorsimplybelowit.
Herehowitwouldbedone.
1

Newimagesize:
Asitcanbeseenfromtheaboveexample,thatanoriginalimageof2rowsand2columns
hasbeenconvertedinto4rowsand4columnsafterzooming.Thatmeansthenewimage
hasadimensionsof
(Originalimagerows*zoomingfactor,OriginalImagecols*zoomingfactor)

Advantageanddisadvantage:
Oneoftheadvantageofthiszoomingtechniqueis,itisverysimple.Youjusthavetocopy
thepixelsandnothingelse.
Thedisadvantageofthistechniqueisthatimagegotzoomedbuttheoutputisveryblurry.
And as the zooming factor increased , the image got more and more blurred. That would
eventuallyresultinfullyblurredimage.

Method2:Zeroorderhold
Introduction
Zero order hold method is another method of zooming. It is also known as zoom twice.
Becauseitcanonlyzoomtwice.Wewillseeinthebelowexamplethatwhyitdoesthat.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

67/179

10/26/2016

DIPQuickGuide

Working
Inzeroorderholdmethod,wepicktwoadjacentelementsfromtherowsrespectivelyand
thenweaddthemanddividetheresultbytwo,andplacetheirresultinbetweenthosetwo
elements.Wefirstdothisrowwiseandthenwedothiscolumnwise.

Forexample
Letstakeanimageofthedimensionsof2rowsand2columnsandzoomittwiceusingzero
orderhold.
1

Firstwewillzoomitrowwiseandthencolumnwise.

Rowwisezooming
1

Aswetakethefirsttwonumbers:(2+1)=3andthenwedivideitby2,weget1.5which
isapproximatedto1.Thesamemethodisappliedintherow2.

Columnwisezooming
1

Wetaketwoadjacentcolumnpixelvalueswhichare1and3.Weaddthemandgot4.4is
then divided by 2 and we get 2 which is placed in between them. The same method is
appliedinallthecolumns.

Newimagesize
Asyoucanseethatthedimensionsofthenewimageare3x3wheretheoriginalimage
dimensionsare2x2.Soitmeansthatthedimensionsofthenewimagearebasedonthe
followingformula
(2(numberofrows)minus1)X(2(numberofcolumns)minus1)

Advantagesanddisadvantage.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

68/179

10/26/2016

DIPQuickGuide

Oneoftheadvantageofthiszoomingtechnique,thatitdoesnotcreateasblurrypictureas
comparetothenearestneighborinterpolationmethod.Butitalsohasadisadvantagethatit
canonlyrunonthepowerof2.Itcanbedemonstratedhere.

Reasonbehindtwicezooming:
Considertheaboveimageof2rowsand2columns.Ifwehavetozoomit6times,using
zeroorderholdmethod,wecannotdoit.Astheformulashowsusthis.
Itcouldonlyzoominthepowerof22,4,8,16,32andsoon.
Evenifyoutrytozoomit,youcannot.Becauseatfirstwhenyouwillzoomittwotimes,
andtheresultwouldbesameasshowninthecolumnwisezoomingwithdimensionsequal
to3x3.Thenyouwillzoomitagainandyouwillgetdimensionsequalto5x5.Nowifyou
willdoitagain,youwillgetdimensionsequalto9x9.
Whereasaccordingtotheformulaofyourstheanswershouldbe11x11.As(6(2)minus1)
X(6(2)minus1)gives11x11.

Method3:KTimeszooming
Introduction:
Ktimesisthethirdzoomingmethodwearegoingtodiscuss.Itisoneofthemostperfect
zoomingalgorithmdiscussedsofar.Itcatersthechallengesofbothtwicezoomingandpixel
replication.Kinthiszoomingalgorithmstandsforzoomingfactor.

Working:
Itworkslikethisway.
Firstofall,youhavetotaketwoadjacentpixelsasyoudidinthezoomingtwice.Thenyou
havetosubtractthesmallerfromthegreaterone.Wecallthisoutput(OP).
Divide the output(OP) with the zooming factor(K). Now you have to add the result to the
smallervalueandputtheresultinbetweenthosetwovalues.
Add the value OP again to the value you just put and place it again next to the previous
puttedvalue.Youhavetodoittillyouplacek1valuesinit.
Repeatthesamestepforalltherowsandthecolumns,andyougetazoomedimages.

Forexample:
Supposeyouhaveanimageof2rowsand3columns,whichisgivenbelow.Andyouhave
tozoomitthriceorthreetimes.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

69/179

10/26/2016

DIPQuickGuide

15

30

15

30

15

30

Kinthiscaseis3.K=3.
Thenumberofvaluesthatshouldbeinsertedisk1=31=2.

Rowwisezooming
Takethefirsttwoadjacentpixels.Whichare15and30.
Subtract15from30.3015=15.
Divide15byk.15/k=15/3=5.WecallitOP.(whereopisjustaname)
AddOPtolowernumber.15+OP=15+5=20.
AddOPto20again.20+OP=20+5=25.
Wedothat2timesbecausewehavetoinsertk1values.
Nowrepeatthisstepforthenexttwoadjacentpixels.Itisshowninthefirsttable.
Afterinsertingthevalues,youhavetosorttheinsertedvaluesinascendingorder,sothere
remainsasymmetrybetweenthem.
Itisshowninthesecondtable

Table1.
15

20

25

30

20

25

15

30

20

25

15

20

25

30

Table2.

Columnwisezooming
Thesameprocedurehastobeperformedcolumnwise.Theprocedureincludetakingthetwo
adjacentpixelvalues,andthensubtractingthesmallerfromthebiggerone.Thenafterthat
,youhavetodivideitbyk.StoretheresultasOP.AddOPtosmallerone,andthenagain
addOPtothevaluethatcomesinfirstadditionofOP.Insertthenewvalues.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

70/179

10/26/2016

DIPQuickGuide

Herewhatyougotafterallthat.
15

20

25

30

25

20

15

20

21

21

25

21

21

20

25

22

22

20

22

22

25

30

25

20

15

20

25

30

Newimagesize
Thebestwaytocalculatetheformulaforthedimensionsofanewimageistocomparethe
dimensionsoftheoriginalimageandthefinalimage.Thedimensionsoftheoriginalimage
were2X3.Andthedimensionsofthenewimageare4x7.
Theformulathusis:
(K(numberofrowsminus1)+1)X(K(numberofcolsminus1)+1)

Advantagesanddisadvantages
Theoneoftheclearadvantagethatktimezoomingalgorithmhasthatitisabletocompute
zoom of any factor which was the power of pixel replication algorithm , also it gives
improvedresult(lessblurry)whichwasthepowerofzeroorderholdmethod.SohenceIt
comprisesthepowerofthetwoalgorithms.
Theonlydifficultythisalgorithmhasthatithastobesortintheend,whichisanadditional
step,andthusincreasesthecostofcomputation.

SpatialResolution
Imageresolution
Imageresolutioncanbedefinedinmanyways.Onetypeofitwhichispixelresolutionthat
hasbeendiscussedinthetutorialofpixelresolutionandaspectratio.
Inthistutorial,wearegoingtodefineanothertypeofresolutionwhichisspatialresolution.

Spatialresolution:
Spatial resolution states that the clarity of an image cannot be determined by the pixel
resolution.Thenumberofpixelsinanimagedoesnotmatter.
Spatialresolutioncanbedefinedasthe

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

71/179

10/26/2016

DIPQuickGuide

smallestdiscernibledetailinanimage.(DigitalImageProcessingGonzalez,Woods2nd
Edition)
Orinotherwaywecandefinespatialresolutionasthenumberofindependentpixelsvalues
perinch.
Inshortwhatspatialresolutionreferstoisthatwecannotcomparetwodifferenttypesof
imagestoseethatwhichoneisclearorwhichoneisnot.Ifwehavetocomparethetwo
images,toseewhichoneismoreclearorwhichhasmorespatialresolution,wehaveto
comparetwoimagesofthesamesize.
Forexample:
Youcannotcomparethesetwoimagestoseetheclarityoftheimage.

Althoughbothimagesareofthesameperson,butthatisnottheconditionwearejudging
on.ThepictureontheleftiszoomedoutpictureofEinsteinwithdimensionsof227x222.
Whereas the picture on the right side has the dimensions of 980 X 749 and also it is a
zoomedimage.Wecannotcomparethemtoseethatwhichoneismoreclear.Remember
the factor of zoom does not matter in this condition, the only thing that matters is that
thesetwopicturesarenotequal.
Soinordertomeasurespatialresolution,thepicturesbelowwouldserverthepurpose.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

72/179

10/26/2016

DIPQuickGuide

Nowyoucancomparethesetwopictures.Boththepictureshassamedimensionswhichare
of227X222.Nowwhenyoucomparethem,youwillseethatthepictureontheleftside
has more spatial resolution or it is more clear then the picture on the right side. That is
becausethepictureontherightisablurredimage.

Measuringspatialresolution:
Sincethespatialresolutionreferstoclarity,sofordifferentdevices,differentmeasurehas
beenmadetomeasureit.

Forexample:
Dotsperinch
Linesperinch
Pixelsperinch
Theyarediscussedinmoredetailinthenexttutorialbutjustabriefintroductionhasbeen
givenbelow.

Dotsperinch:
DotsperinchorDPIisusuallyusedinmonitors.

Linesperinch:
LinesperinchorLPIisusuallyusedinlaserprinters.

Pixelperinch:
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

73/179

10/26/2016

DIPQuickGuide

PixelperinchorPPIismeasurefordifferentdevicessuchastablets,Mobilephonese.t.c.

Pixels,DotsandLinesPerInch
Intheprevioustutorialofspatialresolution,wediscussedthebriefintroductionofPPI,DPI,
LPI.Nowweareformallygoingtodiscussallofthem.

Pixelsperinch.
PixeldensityorPixelsperinchisameasureofspatialresolutionfordifferentdevicesthat
includestablets,mobilephones.
ThehigheristhePPI,thehigheristhequality.Inordertomoreunderstandit,thathowit
calculated.LetscalculatethePPIofamobilephone.

Calculatingpixelsperinch(PPI)ofSamsunggalaxyS4:

TheSamsunggalaxys4hasPPIorpixeldensityof441.Buthowdoesitiscalculated?
FirstofallwewillPythagorastheoremtocalculatethediagonalresolutioninpixels.
Itcanbegivenas:

Whereaandbaretheheightandwidthresolutionsinpixelandcisthediagonalresolution
inpixels.
ForSamsunggalaxys4,itis1080x1920pixels.
Soputtingthosevaluesintheequationgivestheresult
C=2202.90717
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

74/179

10/26/2016

DIPQuickGuide

NowwewillcalculatePPI
PPI=c/diagonalsizeininches
ThediagonalsizeininchesofSamsungalaxys4is5.0inches,whichcanbeconfirmedfrom
anywhere.
PPI=2202.90717/5.0
PPI=440.58
PPI=441(approx)
ThatmeansthatthepixeldensityofSamsunggalaxys4is441PPI.

Dotsperinch.
ThedpiisoftenrelatetoPPI,whereasthereisadifferencebetweenthesetwo.DPIordots
perinchisameasureofspatialresolutionofprinters.Incaseofprinters,dpimeansthat
howmanydotsofinkareprintedperinchwhenanimagegetprintedoutfromtheprinter.
Remember,itisnotnecessarythateachPixelperinchisprintedbyonedotperinch.There
maybemanydotsperinchusedforprintingonepixel.Thereasonbehindthisthatmostof
thecolorprintersusesCMYKmodel.Thecolorsarelimited.Printerhastochoosefromthese
colorstomakethecolorofthepixelwhereaswithinpc,youhavehundredsofthousandsof
colors.
The higher is the dpi of the printer , the higher is the quality of the printed document or
imageonpaper.
Usuallysomeofthelaserprintershavedpiof300andsomehave600ormore.

Linesperinch.
Whendpireferstodotsperinch,linerperinchreferstolinesofdotsperinch.Theresolution
ofhalftonescreenismeasuredinlinesperinch.
Thefollowingtableshowssomeofthelinesperinchcapacityoftheprinters.
Printer

LPI

Screenprinting

4565lpi

Laserprinter(300
dpi)

65lpi

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

75/179

10/26/2016

DIPQuickGuide

Laserprinter(600
dpi)

85105lpi

OffsetPress
(newsprintpaper)

85lpi

OffsetPress(coated
paper)

85185lpi

GrayLevelResolution
Imageresolution:
Aresolutioncanbedefinedasthetotalnumberofpixelsinanimage.Thishasbeendiscussedin
Imageresolution.Andwehavealsodiscussed,thatclarityofanimagedoesnotdependson
numberofpixels,butonthespatialresolutionoftheimage.Thishasbeendiscussedinthespatial
resolution.Herewearegoingtodiscussanothertypeofresolutionwhichiscalledgraylevel
resolution.

Graylevelresolution:
Graylevelresolutionreferstothepredictableordeterministicchangeintheshadesorlevels
ofgrayinanimage.
Inshortgraylevelresolutionisequaltothenumberofbitsperpixel.
Wehavealreadydiscussedbitsperpixelinourtutorialofbitsperpixelandimagestorage
requirements.Wewilldefinebppherebriefly.

BPP:
Thenumberofdifferentcolorsinanimageisdependsonthedepthofcolororbitsperpixel.

Mathematically:
Themathematicalrelationthatcanbeestablishedbetweengraylevelresolutionandbitsper
pixelcanbegivenas.

InthisequationLreferstonumberofgraylevels.Itcanalsobedefinedastheshadesof
gray.Andkreferstobpporbitsperpixel.Sothe2raisetothepowerofbitsperpixelis
equaltothegraylevelresolution.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

76/179

10/26/2016

DIPQuickGuide

Forexample:

TheaboveimageofEinstein is an gray scale image. Means it is an image with 8 bits per


pixelor8bpp.
Nowifweretocalculatethegraylevelresolution,herehowwegonnadoit.

Itmeansitgraylevelresolutionis256.Orinotherwaywecansaythatthisimagehas256
differentshadesofgray.
Themoreisthebitsperpixelofanimage,themoreisitsgraylevelresolution.

Defininggraylevelresolutionintermsofbpp:
Itisnotnecessarythatagraylevelresolutionshouldonlybedefinedintermsoflevels.We
canalsodefineitintermsofbitsperpixel.

Forexample:
Ifyouaregivenanimageof4bpp,andyouareaskedtocalculateitsgraylevelresolution.
Therearetwoanswerstothatquestion.
Thefirstansweris16levels.
Thesecondansweris4bits.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

77/179

10/26/2016

DIPQuickGuide

FindingbppfromGraylevelresolution:
Youcanalsofindthebitsperpixelsfromthegivengraylevelresolution.Forthis,wejust
havetotwisttheformulaalittle.
Equation1.

Thisformulafindsthelevels.Nowifweweretofindthebitsperpixelorinthiscasek,we
willsimplychangeitlikethis.
K=logbase2(L)Equation(2)
Because in the first equation the relationship between Levels (L ) and bits per pixel (k) is
exponentional.Nowwehavetorevertit,andthustheinverseofexponentionalislog.
Letstakeanexampletofindbitsperpixelfromgraylevelresolution.

Forexample:
Ifyouaregivenanimageof256levels.Whatisthebitsperpixelrequiredforit.
Putting256intheequation,weget.
K=logbase2(256)
K=8.
Sotheansweris8bitsperpixel.

Graylevelresolutionandquantization:
Thequantizationwillbeformallyintroducedinthenexttutorial,butherewearejustgoing
toexplaintherelationshipbetweengraylevelresolutionandquantization.
Gray level resolution is found on the y axis of the signal. In the tutorial of Introduction to
signalsandsystem,wehavestudiedthatdigitizingaananalogsignalrequirestwosteps.
Samplingandquantization.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

78/179

10/26/2016

DIPQuickGuide

Samplingisdoneonxaxis.AndquantizationisdoneinYaxis.
Sothatmeansdigitizingthegraylevelresolutionofanimageisdoneinquantization.

ConceptofQuantization
Wehaveintroducedquantizationinourtutorialofsignalsandsystem.Weareformallygoing
torelateitwithdigitalimagesinthistutorial.Letsdiscussfirstalittlebitaboutquantization.

Digitizingasignal.
As we have seen in the previous tutorials , that digitizing an analog signal into a digital ,
requires two basic steps. Sampling and quantization. Sampling is done on x axis. It is the
conversionofxaxis(infinitevalues)todigitalvalues.
Thebelowfigureshowssamplingofasignal.

Samplingwithrelationtodigitalimages:
The concept of sampling is directly related to zooming. The more samples you take , the
morepixels,youget.Oversamplingcanalsobecalledaszooming.Thishasbeendiscussed
undersamplingandzoomingtutorial.
But the story of digitizing a signal does not end at sampling too, there is another step
involvedwhichisknownasQuantization.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

79/179

10/26/2016

DIPQuickGuide

Whatisquantization.
Quantization is opposite to sampling. It is done on y axis. When you are qunaitizing an
image,youareactuallydividingasignalintoquanta(partitions).
On the x axis of the signal , are the coordinate values, and on the y axis , we have
amplitudes.SodigitizingtheamplitudesisknownasQuantization.
Herehowitisdone

You can see in this image , that the signal has been quantified into three different levels.
That means that when we sample an image , we actually gather a lot of values, and in
quantization,wesetlevelstothesevalues.Thiscanbemoreclearintheimagebelow.

Inthefigureshowninsampling,althoughthesampleshasbeentaken,buttheywerestill
spanningverticallytoacontinuousrangeofgraylevelvalues.Inthefigureshownabove,
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

80/179

10/26/2016

DIPQuickGuide

these vertically ranging values have been quantized into 5 different levels or partitions.
Rangingfrom0blackto4white.Thislevelcouldvaryaccordingtothetypeofimageyou
want.
Therelationofquantizationwithgraylevelshasbeenfurtherdiscussedbelow.
RelationofQuantizationwithgraylevelresolution:
The quantized figure shown above has 5 different levels of gray. It means that the image
formedfromthissignal,wouldonlyhave5differentcolors.Itwouldbeablackandwhite
imagemoreorlesswithsomecolorsofgray.Nowifyouweretomakethequalityofthe
imagemorebetter,thereisonethingyoucandohere.Whichis,toincreasethelevels,or
graylevelresolutionup.Ifyouincreasethislevelto256,itmeansyouhaveangrayscale
image.Whichisfarbetterthensimpleblackandwhiteimage.
Now256,or5orwhateverlevelyouchooseiscalledgraylevel.Remembertheformula
thatwediscussedintheprevioustutorialofgraylevelresolutionwhichis,

Wehavediscussedthatgraylevelcanbedefinedintwoways.Whichwerethesetwo.
Graylevel=numberofbitsperpixel(BPP).(kintheequation)
Graylevel=numberoflevelsperpixel.
Inthiscasewehavegraylevelisequalto256.Ifwehavetocalculatethenumberofbits,
wewouldsimplyputthevaluesintheequation.Incaseof256levels,wehave256different
shadesofgrayand8bitsperpixel,hencetheimagewouldbeagrayscaleimage.

Reducingthegraylevel
Nowwewillreducethegraylevelsoftheimagetoseetheeffectontheimage.

Forexample:
Letssayyouhaveanimageof8bpp,thathas256differentlevels.Itisagrayscaleimage
andtheimagelookssomethinglikethis.

256GrayLevels

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

81/179

10/26/2016

DIPQuickGuide

Nowwewillstartreducingthegraylevels.Wewillfirstreducethegraylevelsfrom256to
128.

128GrayLevels

There is not much effect on an image after decrease the gray levels to its half. Lets
decreasesomemore.

64GrayLevels

Stillnotmucheffect,thenletsreducethelevelsmore.

32GrayLevels

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

82/179

10/26/2016

DIPQuickGuide

Surprisedtosee,thatthereisstillsomelittleeffect.Maybeitsduetoreason,thatitis
thepictureofEinstein,butletsreducethelevelsmore.

16GrayLevels

Boomhere,wego,theimagefinallyreveals,thatitiseffectedbythelevels.

8GrayLevels

4GrayLevels

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

83/179

10/26/2016

DIPQuickGuide

Nowbeforereducingit,furthertwo2levels,youcaneasilyseethattheimagehasbeen
distorted badly by reducing the gray levels. Now we will reduce it to 2 levels, which is
nothingbutasimpleblackandwhitelevel.Itmeanstheimagewouldbesimpleblackand
whiteimage.

2GrayLevels

Thatsthelastlevelwecanachieve,becauseifreduceitfurther,itwouldbesimplyablack
image,whichcannotbeinterpreted.

Contouring:
There is an interesting observation here , that as we reduce the number of gray levels ,
thereisaspecialtypeofeffectstartappearingintheimage,whichcanbeseenclearin16
graylevelpicture.ThiseffectisknownasContouring.

Isopreferencecurves:
The answer to this effect , that why it appears , lies in Iso preference curves. They are
discussedinournexttutorialofContouringandIsopreferencecurves.

ISOpreferencecurves
Whatiscontouring?
Aswedecreasethenumberofgraylevelsinanimage,somefalsecolors,oredgesstart
appearingonanimage.ThishasbeenshowninourlasttutorialofQuantization.
Letshavealookatit.
Considerwe,haveanimageof8bpp(agrayscaleimage)with256differentshadesofgray
orgraylevels.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

84/179

10/26/2016

DIPQuickGuide

This above picture has 256 different shades of gray. Now when we reduce it to 128 and
furtherreduceit64,theimageismoreorlessthesame.Butwhenrereduceitfurtherto32
differentlevels,wegotapicturelikethis

If you will look closely , you will find that the effects start appearing on the image.These
effects are more visible when we reduce it further to 16 levels and we got an image like
this.

Theselines,thatstartappearingonthisimageareknownascontouringthatareverymuch
visibleintheaboveimage.

Increaseanddecreaseincontouring
The effect of contouring increase as we reduce the number of gray levels and the effect
decreaseasweincreasethenumberofgraylevels.Theyarebothviceversa

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

85/179

10/26/2016

DIPQuickGuide

VS

That means more quantization , will effect in more contouring and vice versa. But is this
alwaysthecase.TheanswerisNo.Thatdependsonsomethingelsethatisdiscussedbelow.

Isopreferencecurves
Astudyconductedonthiseffectofgraylevelandcontouring,andtheresultswereshownin
thegraphintheformofcurves,knownasIsopreferencecurves.
The phenomena of Isopreference curves shows , that the effect of contouring not only
dependsonthedecreasingofgraylevelresolutionbutalsoontheimagedetail.
Theessenceofthestudyis:
Ifanimagehasmoredetail,theeffectofcontouringwouldstartappearonthisimagelater,
ascomparetoanimagewhichhaslessdetail,whenthegraylevelsarequantized.
Accordingtotheoriginalresearch,theresearcherstookthesethreeimagesandtheyvary
theGraylevelresolution,inallthreeimages.
Theimageswere

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

86/179

10/26/2016

DIPQuickGuide

Levelofdetail:
Thefirstimagehasonlyafaceinit,andhenceverylessdetail.Thesecondimagehassome
other objects in the image too , such as camera man, his camera , camera stand, and
background objects e.t.c. Whereas the third image has more details then all the other
images.

Experiment:
Thegraylevelresolutionwasvariedinalltheimages,andtheaudiencewasaskedtorate
these three images subjectively. After the rating , a graph was drawn according to the
results.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

87/179

10/26/2016

DIPQuickGuide

Result:
The result was drawn on the graph. Each curve on the graph represents one image. The
values on the x axis represents the number of gray levels and the values on the y axis
representsbitsperpixel(k).
Thegraphhasbeenshownbelow.

Accordingtothisgraph,wecanseethatthefirstimagewhichwasofface,wassubjectto
contouring early then all of the other two images. The second image , that was of the
cameraman was subject to contouring a bit after the first image when its gray levels are
reduced.Thisisbecauseithasmoredetailsthenthefirstimage.Andthethirdimagewas
subjecttocontouringalotafterthefirsttwoimagesie:after4bpp.Thisisbecause,this
imagehasmoredetails.

Conclusion:
Soformoredetailedimages,theisopreferencecurvesbecomemoreandmorevertical.It
also means that for an image with a large amount of details , very few gray levels are
needed.

ConceptofDithering
In the last two tutorials of Quantization and contouring , we have seen that reducing the
gray level of an image reduces the number of colors required to denote an image. If the

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

88/179

10/26/2016

DIPQuickGuide

gray levels are reduced two 2 , the image that appears doesnot have much spatial
resolutionorisnotverymuchappealing.

Dithering:
Dithering is the process by which we create illusions of the color that are not present
actually.Itisdonebytherandomarrangementofpixels.
Forexample.Considerthisimage.

Thisisanimagewithonlyblackandwhitepixelsinit.Itspixelsarearrangedinanorderto
form another image that is shown below. Note at the arrangement of pixels has been
changed,butnotthequantityofpixels.

WhyDithering?
Whydoweneeddithering,theanswerofthisliesinitsrelationwithquantization.

Ditheringwithquantization.
Whenweperformquantization,tothelastlevel,weseethattheimagethatcomesinthe
lastlevel(level2)lookslikethis.

Nowaswecanseefromtheimagehere,thatthepictureisnotveryclear,especiallyifyou
will look at the left arm and back of the image of the Einstein. Also this picture does not
havemuchinformationordetailoftheEinstein.
Nowifweweretochangethisimageintosomeimagethatgivesmoredetailthenthis,we
havetoperformdithering.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

89/179

10/26/2016

DIPQuickGuide

Performingdithering.
First of all , we will work on threholding. Dithering is usually working to improve
thresholding.Duringthreholding,thesharpedgesappearwheregradientsaresmoothinan
image.
In thresholding , we simply choose a constant value. All the pixels above that value are
consideredas1andallthevaluebelowitareconsideredas0.
Wegotthisimageafterthresholding.

Sincethereisnotmuchchangeintheimage,asthevaluesarealready0and1orblack
andwhiteinthisimage.
Nowweperformsomerandomditheringtoit.Itssomerandomarrangementofpixels.

Wegotanimagethatgivesslighterofthemoredetails,butitscontrastisverylow.
Sowedosomemoreditheringthatwillincreasethecontrast.Theimagethatwegotisthis:

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

90/179

10/26/2016

DIPQuickGuide

Nowwemixtheconceptsofrandomdithering,alongwiththresholdandwegotanimage
likethis.

Nowyousee,wegotalltheseimagesbyjustrearrangingthepixelsofanimage.Thisre
arrangingcouldberandomorcouldbeaccordingtosomemeasure.

HistogramsIntroduction
Before discussing the use of Histograms in image processing , we will first look at what
histogramis,howitisusedandthenanexampleofhistogramstohavemoreunderstanding
ofhistogram.

Histograms:
Ahistogramisagraph.Agraphthatshowsfrequencyofanything.Usuallyhistogramhave
barsthatrepresentfrequencyofoccurringofdatainthewholedataset.
AHistogramhastwoaxisthexaxisandtheyaxis.
Thexaxiscontainseventwhosefrequencyyouhavetocount.
Theyaxiscontainsfrequency.
Thedifferentheightsofbarshowsdifferentfrequencyofoccurrenceofdata.
Usuallyahistogramlookslikethis.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

91/179

10/26/2016

DIPQuickGuide

Nowwewillseeanexampleofthishistogramisbuild

Example:
Consideraclassofprogrammingstudentsandyouareteachingpythontothem.
Attheendofthesemester,yougotthisresultthatisshownintable.Butitisverymessy
and doesnot show your overall result of class. So you have to make a histogram of your
result,showingtheoverallfrequencyofoccurrenceofgradesinyourclass.Herehowyou
aregoingtodoit.

Resultsheet:
Name

Grade

John

Jack

Carter

Tommy

Lisa

C+

Derek

Tom

B+

Histogramofresultsheet:
Nowwhatyouaregoingtodois,thatyouhavetofindwhatcomesonthexandtheyaxis.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

92/179

10/26/2016

DIPQuickGuide

Thereisonethingtobesure,thatyaxiscontainsthefrequency,sowhatcomesonthex
axis. X axis contains the event whose frequency has to be calculated. In this case x axis
containsgrades.

Nowwewillhowdoweuseahistograminanimage.

Histogramofanimage
Histogram of an image , like other histograms also shows frequency. But an image
histogram , shows frequency of pixels intensity values. In an image histogram, the x axis
showsthegraylevelintensitiesandtheyaxisshowsthefrequencyoftheseintensities.

Forexample:

ThehistogramoftheabovepictureoftheEinsteinwouldbesomethinglikethis

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

93/179

10/26/2016

DIPQuickGuide

Thexaxisofthehistogramshowstherangeofpixelvalues.Sinceitsan8bppimage,that
meansithas256levelsofgrayorshadesofgrayinit.Thatswhytherangeofxaxisstarts
from 0 and end at 255 with a gap of 50. Whereas on the y axis , is the count of these
intensities.
Asyoucanseefromthegraph,thatmostofthebarsthathavehighfrequencyliesinthe
first half portion which is the darker portion. That means that the image we have got is
darker.Andthiscanbeprovedfromtheimagetoo.

ApplicationsofHistograms:
Histogramshasmanyusesinimageprocessing.Thefirstuseasithasalsobeendiscussed
above is the analysis of the image. We can predict about an image by just looking at its
histogram.Itslikelookinganxrayofaboneofabody.
Theseconduseofhistogramisforbrightnesspurposes.Thehistogramshaswideapplication
in image brightness. Not only in brightness , but histograms are also used in adjusting
contrastofanimage.
Anotherimportantuseofhistogramistoequalizeanimage.
And last but not the least, histogram has wide use in thresholding. This is mostly used in
computervision.

BrightnessandContrast
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

94/179

10/26/2016

DIPQuickGuide

Brightness:
Brightness is a relative term. It depends on your visual perception. Since brightness is a
relativeterm,sobrightnesscanbedefinedastheamountofenergyoutputbyasourceof
lightrelativetothesourcewearecomparingitto.Insomecaseswecaneasilysaythatthe
imageisbright,andinsomecases,itsnoteasytoperceive.

Forexample:
Justhavealookatbothoftheseimages,andcomparewhichoneisbrighter.

Wecaneasilysee,thattheimageontherightsideisbrighterascomparedtotheimageon
theleft.
Butiftheimageontherightismademoredarkerthenthefirstone,thenwecansaythat
theimageontheleftismorebrighterthentheleft.

Howtomakeanimagebrighter.
Brightness can be simply increased or decreased by simple addition or subtraction, to the
imagematrix.
Considerthisblackimageof5rowsand5columns

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

95/179

10/26/2016

DIPQuickGuide

Sincewealreadyknow,thateachimagehasamatrixatitsbehindthatcontainsthepixel
values.Thisimagematrixisgivenbelow.
0

Sincethewholematrixisfilledwithzero,andtheimageisverymuchdarker.
Nowwewillcompareitwithanothersameblackimagetoseethisimagegotbrighterornot.

Stillboththeimagesaresame,nowwewillperformsomeoperationsonimage1,dueto
whichitbecomesbrighterthenthesecondone.
Whatwewilldois,thatwewillsimplyaddavalueof1toeachofthematrixvalueofimage
1.Afteraddingtheimage1wouldsomethinglikethis.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

96/179

10/26/2016

DIPQuickGuide

Nowwewillagaincompareitwithimage2,andseeanydifference.

Wesee,thatstillwecannottellwhichimageisbrighterasbothimageslooksthesame.
Nowwhatwewilldo,isthatwewilladd50toeachofthematrixvalueoftheimage1and
seewhattheimagehasbecome.
Theoutputisgivenbelow.

Nowagain,wewillcompareitwithimage2.

Nowyoucanseethattheimage1isslightlybrighterthentheimage2.Wegoon,andadd
another45valuetoitsmatrixofimage1,andthistimewecompareagainbothimages.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

97/179

10/26/2016

DIPQuickGuide

Nowwhenyoucompareit,youcanseethatthisimage1isclearlybrighterthentheimage
2.
Evenitisbrighterthentheoldimage1.Atthispointthematrixoftheimage1contains100
ateachindexasfirstadd5,then50,then45.So5+50+45=100.

Contrast
Contrastcanbesimplyexplainedasthedifferencebetweenmaximumandminimumpixel
intensityinanimage.

Forexample.
Considerthefinalimage1inbrightness.

Thematrixofthisimageis:
100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

100

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

98/179

10/26/2016

DIPQuickGuide

Themaximumvalueinthismatrixis100.
Theminimumvalueinthismatrixis100.
Contrast=maximumpixelintensity(subtractedby)minimumpixelintensity
=100(subtractedby)100
=0
0meansthatthisimagehas0contrast.

ImageTransformations
Beforewediscuss,whatisimagetransformation,wewilldiscusswhatatransformationis.

Transformation.
Transformationisafunction.Afunctionthatmapsonesettoanothersetafterperforming
someoperations.

DigitalImageProcessingsystem:
Wehavealreadyseenintheintroductorytutorialsthatindigitalimageprocessing,wewill
developasystemthatwhoseinputwouldbeanimageandoutputwouldbeanimagetoo.
Andthesystemwouldperformsomeprocessingontheinputimageandgivesitsoutputas
anprocessedimage.Itisshownbelow.

Now function applied inside this digital system that process an image and convert it into
outputcanbecalledastransformationfunction.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

99/179

10/26/2016

DIPQuickGuide

Asitshowstransformationorrelation,thathowanimage1isconvertedtoimage2.

Imagetransformation.
Considerthisequation
G(x,y)=T{f(x,y)}
Inthisequation,
F(x,y)=inputimageonwhichtransformationfunctionhastobeapplied.
G(x,y)=theoutputimageorprocessedimage.
Tisthetransformationfunction.
Thisrelationbetweeninputimageandtheprocessedoutputimagecanalsoberepresented
as.
s=T(r)
whererisactuallythepixelvalueorgraylevelintensityoff(x,y)atanypoint.Andsisthe
pixelvalueorgraylevelintensityofg(x,y)atanypoint.
The basic gray level transformation has been discussed in our tutorial of basic gray level
transformations.
Nowwearegoingtodiscusssomeoftheverybasictransformationfunctions.

Examples:
Considerthistransformationfunction.

Letstakethepointrtobe256,andthepointptobe127.Considerthisimagetobeaone
bppimage.Thatmeanswehaveonlytwolevelsofintensitiesthatare0and1.Sointhis
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

100/179

10/26/2016

DIPQuickGuide

casethetransformationshownbythegraphcanbeexplainedas.
Allthepixelintensityvaluesthatarebelow127(pointp)are0,meansblack.Andallthe
pixelintensityvaluesthataregreaterthen127,are1,thatmeanswhite.Butattheexact
pointof127,thereisasuddenchangeintransmission,sowecannottellthatatthatexact
point,thevaluewouldbe0or1.
Mathematicallythistransformationfunctioncanbedenotedas:

Consideranothertransformationlikethis:

Nowifyouwilllookatthisparticulargraph,youwillseeastraighttransitionlinebetween
inputimageandoutputimage.
Itshowsthatforeachpixelorintensityvalueofinputimage,thereisasameintensityvalue
ofoutputimage.Thatmeanstheoutputimageisexactreplicaoftheinputimage.
Itcanbemathematicallyrepresentedas:
g(x,y)=f(x,y)
theinputandoutputimagewouldbeinthiscaseareshownbelow.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

101/179

10/26/2016

DIPQuickGuide

HistogramSliding
The basic concept of histograms has been discussed in the tutorial of Introduction to
histograms.Butwewillbrieflyintroducethehistogramhere.

Histogram:
Histogram is nothing but a graph that shows frequency of occurrence of data. Histograms
hasmanyuseinimageprocessing,outofwhichwearegoingtodiscussoneuserherewhich
iscalledhistogramsliding.

Histogramsliding.
Inhistogramsliding,wejustsimplyshiftacompletehistogramrightwardsorleftwards.Due
toshiftingorslidingofhistogramtowardsrightorleft,aclearchangecanbeseeninthe
image.Inthistutorialwearegoingtousehistogramslidingformanipulatingbrightness.
Thetermie:Brightnesshasbeendiscussedinourtutorialofintroductiontobrightnessand
contrast.Butwearegoingtobrieflydefinehere.

Brightness:
Brightness is a relative term. Brightness can be defined as intensity of light emit by a
particularlightsource.

Contrast:
Contrastcanbedefinedasthedifferencebetweenmaximumandminimumpixelintensityin
animage.

SlidingHistograms
Increasingbrightnessusinghistogramsliding

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

102/179

10/26/2016

DIPQuickGuide

Histogramofthisimagehasbeenshownbelow.

Ontheyaxisofthishistogramarethefrequencyorcount.Andonthexaxis,wehavegray
level values. As you can see from the above histogram , that those gray level intensities
whosecountismorethen700,liesinthefirsthalfportion,meanstowardsblackerportion.
Thatswhywegotanimagethatisabitdarker.
Inordertobrightit,wewillslideitshistogramtowardsright,ortowardswhiterportion.In
ordertodoweneedtoaddatleastavalueof50tothisimage.Becausewecanseefrom
thehistogramabove,thatthisimagealsohas0pixelintensities,thatarepureblack.Soif
weadd0to50,wewillshiftallthevaluesliesat0intensityto50intensityandalltherest
ofthevalueswillbeshiftedaccordingly.
Letsdoit.

Herewhatwegotafteradding50toeachpixelintensity.
Theimagehasbeenshownbelow.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

103/179

10/26/2016

DIPQuickGuide

Anditshistogramhasbeenshownbelow.

Letscomparethesetwoimagesandtheirhistogramstoseethatwhatchangehavetogot.

Conclusion:
As we can clearly see from the new histogram that all the pixels values has been shifted
towardsrightanditseffectcanbeseeninthenewimage.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

104/179

10/26/2016

DIPQuickGuide

Decreasingbrightnessusinghistogramsliding
Now if we were to decrease brightness of this new image to such an extent that the old
imagelookbrighter,wegottosubtractsomevaluefromallthematrixofthenewimage.
Thevaluewhichwearegoingtosubtractis80.Becausewealreadyadd50totheoriginal
image and we got a new brighter image, now if we want to make it darker , we have to
subtractatleastmorethan50fromit.
Andthiswhatwegotaftersubtracting80fromthenewimage.

Conclusion:
Itisclearfromthehistogramofthenewimage,thatallthepixelvalueshasbeenshifted
towardsrightandthus,itcanbevalidatedfromtheimagethatnewimageisdarkerand
nowtheoriginalimagelookbrighterascomparetothisnewimage.

Histogramstretching
OneoftheotheradvantageofHistogramsthatwediscussedinourtutorialofintroduction
tohistogramsiscontrastenhancement.
There are two methods of enhancing contrast. The first one is called Histogram stretching
that increase contrast. The second one is called Histogram equalization that enhance
contrastandithasbeendiscussedinourtutorialofhistogramequalization.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

105/179

10/26/2016

DIPQuickGuide

Beforewewilldiscussthehistogramstretchingtoincreasecontrast,wewillbrieflydefine
contrast.

Contrast.
Contrastisthedifferencebetweenmaximumandminimumpixelintensity.
Considerthisimage.

Thehistogramofthisimageisshownbelow.

Nowwecalculatecontrastfromthisimage.
Contrast=225.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

106/179

10/26/2016

DIPQuickGuide

Nowwewillincreasethecontrastoftheimage.

Increasingthecontrastoftheimage:
Theformulaforstretchingthehistogramoftheimagetoincreasethecontrastis

Theformularequiresfindingtheminimumandmaximumpixelintensitymultiplybylevelsof
gray.Inourcasetheimageis8bpp,solevelsofgrayare256.
Theminimumvalueis0andthemaximumvalueis225.Sotheformulainourcaseis

wheref(x,y)denotesthevalueofeachpixelintensity.Foreachf(x,y)inanimage,wewill
calculatethisformula.
Afterdoingthis,wewillbeabletoenhanceourcontrast.
Thefollowingimageappearafterapplyinghistogramstretching.

Thestretchedhistogramofthisimagehasbeenshownbelow.
Note the shape and symmetry of histogram. The histogram is now stretched or in other
meansexpand.Havealookatit.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

107/179

10/26/2016

DIPQuickGuide

Inthiscasethecontrastoftheimagecanbecalculatedas
Contrast=240
Hencewecansaythatthecontrastoftheimageisincreased.
Note:thismethodofincreasingcontrastdoesnotworkalways,butitfailsonsomecases.

Failingofhistogramstretching
Aswehavediscussed,thatthealgorithmfailsonsomecases.Thosecasesincludeimages
withwhenthereispixelintensity0and255arepresentintheimage
Becausewhenpixelintensities0and255arepresentinanimage,theninthatcasethey
becometheminimumandmaximumpixelintensitywhichruinstheformulalikethis.
OriginalFormula

Puttingfailcasevaluesintheformula:

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

108/179

10/26/2016

DIPQuickGuide

Simplifythatexpressiongives

That means the output image is equal to the processed image. That means there is no
effectofhistogramstretchinghasbeendoneatthisimage.

IntroductiontoProbability
PMFandCDFbothtermsbelongstoprobabilityandstatistics.Nowthequestionthatshould
ariseinyourmind,isthatwhyarewestudyingprobability.Itisbecausethesetwoconcepts
ofPMFandCDFaregoingtobeusedinthenexttutorialofHistogramequalization.Soifyou
dontknowhowtocalculatePMFandCDF,youcannotapplyhistogramequalizationonyour
image
.

WhatisPMF?
PMF stands for probability mass function. As it name suggest , it gives the probability of
eachnumberinthedatasetoryoucansaythatitbasicallygivesthecountorfrequencyof
eachelement.

HowPMFiscalculated:
We will calculate PMF from two different ways. First from a matrix , because in the next
tutorial,wehavetocalculatethePMFfromamatrix,andanimageisnothingmorethena
twodimensionalmatrix.
ThenwewilltakeanotherexampleinwhichwewillcalculatePMFfromthehistogram.
Considerthismatrix.
1

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

109/179

10/26/2016

DIPQuickGuide

NowifweweretocalculatethePMFofthismatrix,herehowwearegoingtodoit.
Atfirst,wewilltakethefirstvalueinthematrix,andthenwewillcount,howmuchtime
this value appears in the whole matrix. After count they can either be represented in a
histogram,orinatablelikethisbelow.

PMF
0

2/25

4/25

3/25

3/25

2/25

4/25

3/25

4/25

Notethatthesumofthecountmustbeequaltototalnumberofvalues.

CalculatingPMFfromhistogram

Theabovehistogramshowsfrequencyofgraylevelvaluesforan8bitsperpixelimage.
Now if we have to calculate its PMF , we will simple look at the count of each bar from
verticalaxisandthendivideitbytotalcount.
SothePMFoftheabovehistogramisthis.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

110/179

10/26/2016

DIPQuickGuide

Another important thing to note in the above histogram is that it is not monotonically
increasing.Soinordertoincreaseitmonotonically,wewillcalculateitsCDF.

WhatisCDF?
CDF stands for cumulative distributive function. It is a function that calculates the
cumulativesumofallthevaluesthatarecalculatedbyPMF.Itbasicallysumstheprevious
one.

Howitiscalculated?
WewillcalculateCDFusingahistogram.Herehowitisdone.Considerthehistogramshown
abovewhichshowsPMF.
Sincethishistogramisnotincreasingmonotonically,sowillmakeitgrowmonotonically.
Wewillsimplykeepthefirstvalueasitis,andtheninthe2ndvalue,wewilladdthefirst
oneandsoon.
HereistheCDFoftheabovePMFfunction.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

111/179

10/26/2016

DIPQuickGuide

Nowasyoucanseefromthegraphabove,thatthefirstvalueofPMFremainasitis.The
secondvalueofPMFisaddedinthefirstvalueandplacedover128.ThethirdvalueofPMF
isaddedinthesecondvalueofCDF,thatgives110/110whichisequalto1.
And also now , the function is growing monotonically which is necessary condition for
histogramequalization.

PMFandCDFusageinhistogramequalization
Histogramequalization.
Histogramequalizationisdiscussedinthenexttutorialbutabriefintroductionofhistogram
equalizationisgivenbelow.
Histogramequalizationisusedforenhancingthecontrastoftheimages.
PMF and CDF are both use in histogram equalization as it is described in the beginning of
thistutorial.Inthehistogramequalization,thefirstandthesecondsteparePMFandCDF.
Since in histogram equalization , we have to equalize all the pixel values of an image. So
PMFhelpsuscalculatingtheprobabilityofeachpixelvalueinanimage.AndCDFgivesus
thecumulativesumofthesevalues.Furtheron,thisCDFismultipliedbylevels,tofindthe
newpixelintensities,whicharemappedintooldvalues,andyourhistogramisequalized.

HistogramEqualization
We have already seen that contrast can be increased using histogram stretching. In this
tutorialwewillseethathowhistogramequalizationcanbeusedtoenhancecontrast.
Before performing histogram equalization, you must know two important concepts used in
equalizinghistograms.ThesetwoconceptsareknownasPMFandCDF.
TheyarediscussedinourtutorialofPMFandCDF.Pleasevisittheminordertosuccessfully
grasptheconceptofhistogramequalization.

HistogramEqualization:
Histogram equalization is used to enhance contrast. It is not necessary that contrast will
always be increase in this. There may be some cases were histogram equalization can be
worse.Inthatcasesthecontrastisdecreased.
Letsstarthistogramequalizationbytakingthisimagebelowasasimpleimage.
Image

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

112/179

10/26/2016

DIPQuickGuide

Histogramofthisimage:
Thehistogramofthisimagehasbeenshownbelow.

Nowwewillperformhistogramequalizationtoit.

PMF:
FirstwehavetocalculatethePMF(probabilitymassfunction)ofallthepixelsinthisimage.
IfyoudonotknowhowtocalculatePMF,pleasevisitourtutorialofPMFcalculation.

CDF:
Our next step involves calculation of CDF (cumulative distributive function). Again if you
donotknowhowtocalculateCDF,pleasevisitourtutorialofCDFcalculation.

CalculateCDFaccordingtograylevels
Letsforinstanceconsiderthis,thattheCDFcalculatedinthesecondsteplookslikethis.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

113/179

10/26/2016

DIPQuickGuide

GrayLevelValue

CDF

0.11

0.22

0.55

0.66

0.77

0.88

0.99

TheninthisstepyouwillmultiplytheCDFvaluewith(Graylevels(minus)1).
Consideringwehavean3bppimage.Thennumberoflevelswehaveare8.And1subtracts
8is7.SowemultiplyCDFby7.Herewhatwegotaftermultiplying.
GrayLevelValue

CDF

CDF*(Levels1)

0.11

0.22

0.55

0.66

0.77

0.88

0.99

Now we have is the last step , in which we have to map the new gray level values into
numberofpixels.
Letsassumeouroldgraylevelsvalueshasthesenumberofpixels.
GrayLevelValue

Frequency

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

114/179

10/26/2016

DIPQuickGuide

10

12

14

16

Nowifwemapournewvaluesto,thenthisiswhatwegot.
GrayLevelValue

NewGrayLevelValue

Frequency

10

12

14

16

Nowmapthesenewvaluesyouareontohistogram,andyouaredone.
Lets apply this technique to our original image. After applying we got the following image
anditsfollowinghistogram.

HistogramEqualizationImage

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

115/179

10/26/2016

DIPQuickGuide

CumulativeDistributivefunctionofthisimage

HistogramEqualizationhistogram

Comparingboththehistogramsandimages

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

116/179

10/26/2016

DIPQuickGuide

Conclusion
Asyoucanclearlyseefromtheimagesthatthenewimagecontrasthasbeenenhancedand
itshistogramhasalsobeenequalized.Thereisalsooneimportantthingtobenoteherethat
during histogram equalization the overall shape of the histogram changes, where as in
histogramstretchingtheoverallshapeofhistogramremainssame.

GrayLevelTransformation
WehavediscussedsomeofthebasictransformationsinourtutorialofBasictransformation.
Inthistutorialwewilllookatsomeofthebasicgrayleveltransformations.

Imageenhancement
Enhancinganimageprovidesbettercontrastandamoredetailedimageascomparetonon
enhancedimage.Imageenhancementhasveryapplications.Itisusedtoenhancemedical
images,imagescapturedinremotesensing,imagesfromsatellitee.t.c

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

117/179

10/26/2016

DIPQuickGuide

Thetransformationfunctionhasbeengivenbelow
s=T(r)
where r is the pixels of the input image and s is the pixels of the output image. T is a
transformationfunctionthatmapseachvalueofrtoeachvalueofs.Imageenhancement
canbedonethroughgrayleveltransformationswhicharediscussedbelow.

Grayleveltransformation
Therearethreebasicgrayleveltransformation.
Linear
Logarithmic
Powerlaw
Theoverallgraphofthesetransitionshasbeenshownbelow.

Lineartransformation
Firstwewilllookatthelineartransformation.Lineartransformationincludessimpleidentity
and negative transformation. Identity transformation has been discussed in our tutorial of
imagetransformation,butabriefdescriptionofthistransformationhasbeengivenhere.
Identity transition is shown by a straight line. In this transition, each value of the input
image is directly mapped to each other value of output image. That results in the same
input image and output image. And hence is called identity transformation. It has been
shownbelow
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

118/179

10/26/2016

DIPQuickGuide

Negativetransformation
The second linear transformation is negative transformation, which is invert of identity
transformation.Innegativetransformation,eachvalueoftheinputimageissubtractedfrom
theL1andmappedontotheoutputimage.
Theresultissomewhatlikethis.

InputImage

OutputImage

Inthiscasethefollowingtransitionhasbeendone.
s=(L1)r

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

119/179

10/26/2016

DIPQuickGuide

sincetheinputimageofEinsteinisan8bppimage,sothenumberoflevelsinthisimage
are256.Putting256intheequation,wegetthis
s=255r
Soeachvalueissubtractedby255andtheresultimagehasbeenshownabove.Sowhat
happensisthat,thelighterpixelsbecomedarkandthedarkerpicturebecomeslight.Andit
resultsinimagenegative.
Ithasbeenshowninthegraphbelow.

Logarithmictransformations:
Logarithmictransformationfurthercontainstwotypeoftransformation.Logtransformation
andinverselogtransformation.

Logtransformation
Thelogtransformationscanbedefinedbythisformula
s=clog(r+1).
Wheresandrarethepixelvaluesoftheoutputandtheinputimageandcisaconstant.
Thevalue1isaddedtoeachofthepixelvalueoftheinputimagebecauseifthereisapixel
intensity of 0 in the image, then log (0) is equal to infinity. So 1 is added , to make the
minimumvalueatleast1.
During log transformation , the dark pixels in an image are expanded as compare to the
higher pixel values. The higher pixel values are kind of compressed in log transformation.
Thisresultinfollowingimageenhancement.
Thevalueofcinthelogtransformadjustthekindofenhancementyouarelookingfor.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

120/179

10/26/2016

DIPQuickGuide

InputImage

LogTranformImage

Theinverselogtransformisoppositetologtransform.

PowerLawtransformations
There are further two transformation is power law transformations, that include nth power
andnthroottransformation.Thesetransformationscanbegivenbytheexpression:
s=cr^
Thissymboliscalledgamma,duetowhichthistransformationisalsoknownasgamma
transformation.
Variationinthevalueofvariestheenhancementoftheimages.Differentdisplaydevices/
monitorshavetheirowngammacorrection,thatswhytheydisplaytheirimageatdifferent
intensity.
This type of transformation is used for enhancing images for different type of display
devices. The gamma of different display devices is different. For example Gamma of CRT
liesinbetweenof1.8to2.5,thatmeanstheimagedisplayedonCRTisdark.

Correctinggamma.
s=cr^
s=cr^(1/2.5)
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

121/179

10/26/2016

DIPQuickGuide

Thesameimagebutwithdifferentgammavalueshasbeenshownhere.

Forexample:
Gamma=10

Gamma=8

Gamma=6

ConceptofConvolution
This tutorial is about one of the very important concept of signals and system. We will
completelydiscussconvolution.Whatisit?Whyisit?Whatcanweachievewithit?
Wewillstartdiscussingconvolutionfromthebasicsofimageprocessing.

Whatisimageprocessing.
Aswehavediscussedintheintroductiontoimageprocessingtutorialsandinthesignaland
systemthatimageprocessingismoreorlessthestudyofsignalsandsystemsbecausean
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

122/179

10/26/2016

DIPQuickGuide

imageisnothingbutatwodimensionalsignal.
Alsowehavediscussed,thatinimageprocessing,wearedevelopingasystemwhoseinput
isanimageandoutputwouldbeanimage.Thisispictoriallyrepresentedas.

TheboxisthatisshownintheabovefigurelabeledasDigitalImageProcessingsystem
couldbethoughtofasablackbox
Itcanbebetterrepresentedas:

Wherehavewereacheduntilnow
Tillnowwehavediscussedtwoimportantmethodstomanipulateimages.Orinotherwords
wecansaythat,ourblackboxworksintwodifferentwaystillnow.
Thetwodifferentwaysofmanipulatingimageswere

Graphs(Histograms)

This method is known as histogram processing. We have discussed it in detail in previous


tutorialsforincreasecontrast,imageenhancement,brightnesse.t.c
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

123/179

10/26/2016

DIPQuickGuide

Transformationfunctions

This method is known as transformations , in which we discussed different type of


transformationsandsomegrayleveltransformations

Anotherwayofdealingimages
Herewearegoingtodiscussanothermethodofdealingwithimages.Thisothermethodis
known as convolution. Usually the black box(system) used for image processing is an LTI
systemorlineartimeinvariantsystem.Bylinearwemeanthatsuchasystemwhereoutput
is always linear , neither log nor exponent or any other. And by time invariant we means
thatasystemwhichremainssameduringtime.
Sonowwearegoingtousethisthirdmethod.Itcanberepresentedas.

Itcanbemathematicallyrepresentedastwoways
g(x,y)=h(x,y)*f(x,y)
Itcanbeexplainedasthemaskconvolvedwithanimage.
Or
g(x,y)=f(x,y)*h(x,y)
Itcanbeexplainedasimageconvolvedwithmask.
Therearetwowaystorepresentthisbecausetheconvolutionoperator(*)iscommutative.
Theh(x,y)isthemaskorfilter.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

124/179

10/26/2016

DIPQuickGuide

Whatismask?
Mask is also a signal. It can be represented by a two dimensional matrix. The mask is
usually of the order of 1x1, 3x3, 5x5 , 7x7 . A mask should always be in odd number ,
becauseotherwiseyoucannotfindthemidofthemask.Whydoweneedtofindthemidof
themask.Theanswerliesbelow,intopicof,howtoperformconvolution?

Howtoperformconvolution?
Inordertoperformconvolutiononanimage,followingstepsshouldbetaken.
Flipthemask(horizontallyandvertically)onlyonce
Slidethemaskontotheimage.
Multiplythecorrespondingelementsandthenaddthem
Repeatthisprocedureuntilallvaluesoftheimagehasbeencalculated.

Exampleofconvolution
Letsperformsomeconvolution.Step1istoflipthemask.

Mask:
Letstakeourmasktobethis.
1

Flippingthemaskhorizontally

Flippingthemaskvertically

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

125/179

10/26/2016

DIPQuickGuide

Image:
Letsconsideranimagetobelikethis
2

10

12

14

16

18

Convolution
Convolvingmaskoverimage.Itisdoneinthisway.Placethecenterofthemaskateach
elementofanimage.Multiplythecorrespondingelementsandthenaddthem,andpaste
theresultontotheelementoftheimageonwhichyouplacethecenterofmask.

Theboxinredcoloristhemask,andthevaluesintheorangearethevaluesofthemask.
Theblackcolorboxandvaluesbelongtotheimage.Nowforthefirstpixeloftheimage,the
valuewillbecalculatedas
Firstpixel=(5*2)+(4*4)+(2*8)+(1*10)
=10+16+16+10
=52
Place52intheoriginalimageatthefirstindexandrepeatthisprocedureforeachpixelof
theimage.

WhyConvolution
Convolutioncanachievesomething,thattheprevioustwomethodsofmanipulatingimages
cantachieve.Thoseincludetheblurring,sharpening,edgedetection,noisereductione.t.c

ConceptofMask
Whatisamask.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

126/179

10/26/2016

DIPQuickGuide

A mask is a filter. Concept of masking is also known as spatial filtering. Masking is also
knownasfiltering.Inthisconceptwejustdealwiththefilteringoperationthatisperformed
directlyontheimage.

Asamplemaskhasbeenshownbelow
1

Whatisfiltering.
Theprocessoffilteringisalsoknownasconvolvingamaskwithanimage.Asthisprocessis
sameofconvolutionsofiltermasksarealsoknownasconvolutionmasks.

Howitisdone.
The general process of filtering and applying masks is consists of moving the filter mask
frompointtopointinanimage.Ateachpoint(x,y)oftheoriginalimage,theresponseofa
filteriscalculatedbyapredefinedrelationship.Allthefiltersvaluesarepredefinedandare
astandard.

Typesoffilters
Generallytherearetwotypesoffilters.Oneiscalledaslinearfiltersorsmoothingfiltersand
othersarecalledasfrequencydomainfilters.

Whyfiltersareused?
Filters are applied on image for multiple purposes. The two most common uses are as
following:
FiltersareusedforBlurringandnoisereduction
Filtersareusedoredgedetectionandsharpness

Blurringandnoisereduction:
Filtersaremostcommonlyusedforblurringandfornoisereduction.Blurringisusedinpre
processing steps, such as removal of small details from an image prior to large object
extraction.

Masksforblurring.
Thecommonmasksforblurringare.
Boxfilter
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

127/179

10/26/2016

DIPQuickGuide

Weightedaveragefilter
In the process of blurring we reduce the edge content in an image and try to make the
transitionsbetweendifferentpixelintensitiesassmoothaspossible.
Noisereductionisalsopossiblewiththehelpofblurring.

EdgeDetectionandsharpness:
Masksorfilterscanalsobeusedforedgedetectioninanimageandtoincreasesharpness
ofanimage.

Whatareedges.
We can also say that sudden changes of discontinuities in an image are called as edges.
Significanttransitionsinanimagearecalledasedges.Apicturewithedgesisshownbelow.

Originalpicture.

Samepicturewithedges

ConceptofBlurring
A brief introduction of blurring has been discussed in our previous tutorial of concept of
masks,butweareformallygoingtodiscussithere.

Blurring
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

128/179

10/26/2016

DIPQuickGuide

Inblurring,wesimplebluranimage.Animagelooksmoresharpormoredetailedifweare
abletoperceivealltheobjectsandtheirshapescorrectlyinit.Forexample.Animagewith
aface,looksclearwhenweareabletoidentifyeyes,ears,nose,lips,foreheade.t.cvery
clear.Thisshapeofanobjectisduetoitsedges.Soinblurring,wesimplereducetheedge
contentandmakesthetransitionformonecolortotheotherverysmooth.

Blurringvszooming.
Youmighthaveseenablurredimagewhenyouzoomanimage.Whenyouzoomanimage
using pixel replication , and zooming factor is increased, you saw a blurred image. This
imagealsohaslessdetails,butitisnottrueblurring.
Becauseinzooming,youaddnewpixelstoanimage,thatincreasetheoverallnumberof
pixels in an image , whereas in blurring , the number of pixels of a normal image and a
blurredimageremainsthesame.

Commonexampleofablurredimage.

Typesoffilters.
Blurring can be achieved by many ways. The common type of filters that are used to
performblurringare.
Meanfilter
Weightedaveragefilter
Gaussianfilter
Out of these three , we are going to discuss the first two here and Gaussian will be
discussedlateronintheupcomingtutorials.

Meanfilter.
Mean filter is also known as Box filter and average filter. A mean filter has the following
properties.
Itmustbeoddordered
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

129/179

10/26/2016

DIPQuickGuide

Thesumofalltheelementsshouldbe1
Alltheelementsshouldbesame
Ifwefollowthisrule,thenforamaskof3x3.Wegetthefollowingresult.
1/9

1/9

1/9

1/9

1/9

1/9

1/9

1/9

1/9

Since it is a 3x3 mask, that means it has 9 cells. The condition that all the element sum
shouldbeequalto1canbeachievedbydividingeachvalueby9.As
1/9+1/9+1/9+1/9+1/9+1/9+1/9+1/9+1/9=9/9=1

Theresultofamaskof3x3onanimageisshownbelow.
OriginalImage:

BlurredImage

May be the results are not much clear. Lets increase the blurring. The blurring can be
increasedbyincreasingthesizeofthemask.Themoreisthesizeofthemask,themoreis
the blurring. Because with greater mask , greater number of pixels are catered and one
smoothtransitionisdefined.

Theresultofamaskof5x5onanimageisshownbelow.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

130/179

10/26/2016

DIPQuickGuide

OriginalImage:

BlurredImage:

Samewayifweincreasethemask,theblurringwouldbemoreandtheresultsareshown
below.

Theresultofamaskof7x7onanimageisshownbelow.
OriginalImage:

BlurredImage:

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

131/179

10/26/2016

DIPQuickGuide

Theresultofamaskof9x9onanimageisshownbelow.
OriginalImage:

BlurredImage:

Theresultofamaskof11x11onanimageisshownbelow.
OriginalImage:

BlurredImage:

Weightedaveragefilter.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

132/179

10/26/2016

DIPQuickGuide

In weighted average filter, we gave more weight to the center value. Due to which the
contributionofcenterbecomesmorethentherestofthevalues.Duetoweightedaverage
filtering,wecanactuallycontroltheblurring.
Propertiesoftheweightedaveragefilterare.
Itmustbeoddordered
Thesumofalltheelementsshouldbe1
Theweightofcenterelementshouldbemorethenalloftheotherelements

Filter1
1

Thetwopropertiesaresatisfiedwhichare(1and3).Buttheproperty2isnotsatisfied.So
inordertosatisfythatwewillsimpledividethewholefilterby10,ormultiplyitwith1/10.

Filter2
1

10

Dividingfactor=18.

ConceptofEdgeDetection
Wehavediscussedbrieflyaboutedgedetectioninourtutorialofintroductiontomasks.We
willformallydiscussedgedetectionhere.

Whatareedges.
We can also say that sudden changes of discontinuities in an image are called as edges.
Significanttransitionsinanimagearecalledasedges.

Typesofedges.
Geenerallyedgesareofthreetypes:

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

133/179

10/26/2016

DIPQuickGuide

Horizontaledges
VerticalEdges
DiagonalEdges

Whydetectedges.
Most of the shape information of an image is enclosed in edges. So first we detect these
edgesinanimageandbyusingthesefiltersandthenbyenhancingthoseareasofimage
whichcontainsedges,sharpnessoftheimagewillincreaseandimagewillbecomeclearer.
Here are some of the masks for edge detection that we will discuss in the upcoming
tutorials.
PrewittOperator
SobelOperator
RobinsonCompassMasks
KrischCompassMasks
LaplacianOperator.
AbovementionedallthefiltersareLinearfiltersorsmoothingfilters.

PrewittOperator
Prewittoperatorisusedfordetectingedgeshorizontallyandvertically.

SobelOperator
ThesobeloperatorisverysimilartoPrewittoperator.Itisalsoaderivatemaskandisused
foredgedetection.Italsocalculatesedgesinbothhorizontalandverticaldirection.

RobinsonCompassMasks
Thisoperatorisalsoknownasdirectionmask.Inthisoperatorwetakeonemaskandrotate
itinallthe8compassmajordirectionstocalculateedgesofeachdirection.

KirschCompassMasks
KirschCompassMaskisalsoaderivativemaskwhichisusedforfindingedges.Kirschmask
isalsousedforcalculatingedgesinallthedirections.

LaplacianOperator.
Laplacian Operator is also a derivative operator which is used to find edges in an image.
Laplacianisasecondorderderivativemask.Itcanbefurtherdividedintopositivelaplacian
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

134/179

10/26/2016

DIPQuickGuide

andnegativelaplacian.
Allthesemasksfindedges.Somefindhorizontallyandvertically,somefindinonedirection
onlyandsomefindinallthedirections.Thenextconceptthatcomesafterthisissharpening
whichcanbedoneoncetheedgesareextractedfromtheimage

Sharpening:
Sharpening is opposite to the blurring. In blurring, we reduce the edge content and in
sharpneng , we increase the edge content. So in order to increase the edge content in an
image,wehavetofindedgesfirst.
Edgescanbefindbyoneoftheanymethoddescribedabovebyusinganyoperator.After
findingedges,wewilladdthoseedgesonanimageandthustheimagewouldhavemore
edges,anditwouldlooksharpen.
Thisisonewayofsharpeninganimage.
Thesharpenimageisshownbelow.

OriginalImage

SharpenImage

PrewittOperator
Prewittoperatorisusedforedgedetectioninanimage.Itdetectstwotypesofedges:
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

135/179

10/26/2016

DIPQuickGuide

Horizontaledges
VerticalEdges
Edges are calculated by using difference between corresponding pixel intensities of an
image.Allthemasksthatareusedforedgedetectionarealsoknownasderivativemasks.
Becauseaswehavestatedmanytimesbeforeinthisseriesoftutorialsthatimageisalsoa
signalsochangesinasignalcanonlybecalculatedusingdifferentiation.Sothatswhythese
operatorsarealsocalledasderivativeoperatorsorderivativemasks.
Allthederivativemasksshouldhavethefollowingproperties:
Oppositesignshouldbepresentinthemask.
Sumofmaskshouldbeequaltozero.
Moreweightmeansmoreedgedetection.
Prewittoperatorprovidesustwomasksonefordetectingedgesinhorizontaldirectionand
anotherfordetectingedgesinanverticaldirection.

Verticaldirection:
1

Abovemaskwillfindtheedgesinverticaldirectionanditisbecausethezeroscolumninthe
verticaldirection.Whenyouwillconvolvethismaskonanimage,itwillgiveyouthevertical
edgesinanimage.

Howitworks:
Whenweapplythismaskontheimageitprominentverticaledges.Itsimplyworkslikeas
firstorderderivateandcalculatesthedifferenceofpixelintensitiesinaedgeregion.Asthe
centercolumnisofzerosoitdoesnotincludetheoriginalvaluesofanimagebutratherit
calculates the difference of right and left pixel values around that edge. This increase the
edgeintensityanditbecomeenhancedcomparativelytotheoriginalimage.

HorizontalDirection:
1

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

136/179

10/26/2016

DIPQuickGuide

Abovemaskwillfindedgesinhorizontaldirectionanditisbecausethatzeroscolumnisin
horizontal direction. When you will convolve this mask onto an image it would prominent
horizontaledgesintheimage.

Howitworks:
Thismaskwillprominentthehorizontaledgesinanimage.Italsoworksontheprincipleof
above mask and calculates difference among the pixel intensities of a particular edge. As
thecenterrowofmaskisconsistofzerossoitdoesnotincludetheoriginalvaluesofedge
intheimagebutratheritcalculatethedifferenceofaboveandbelowpixelintensitiesofthe
particularedge.Thusincreasingthesuddenchangeofintensitiesandmakingtheedgemore
visible. Both the above masks follow the principle of derivate mask. Both masks have
opposite sign in them and both masks sum equals to zero. The third condition will not be
applicableinthisoperatorasboththeabovemasksarestandardizeandwecantchangethe
valueinthem.
Nowitstimetoseethesemasksinaction:

SampleImage:
Followingisasamplepictureonwhichwewillapplyabovetwomasksoneattime.

AfterapplyingVerticalMask:
Afterapplyingverticalmaskontheabovesampleimage,followingimagewillbeobtained.
This image contains vertical edges. You can judge it more correctly by comparing with
horizontaledgespicture.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

137/179

10/26/2016

DIPQuickGuide

AfterapplyingHorizontalMask:
Afterapplyinghorizontalmaskontheabovesampleimage,followingimagewillbeobtained.

Comparison:
As you can see that in the first picture on which we apply vertical mask, all the vertical
edges are more visible than the original image. Similarly in the second picture we have
appliedthehorizontalmaskandinresultallthehorizontaledgesarevisible.Sointhisway
youcanseethatwecandetectbothhorizontalandverticaledgesfromanimage.

SobelOperator
ThesobeloperatorisverysimilartoPrewittoperator.Itisalsoaderivatemaskandisused
foredgedetection.LikePrewittoperatorsobeloperatorisalsousedtodetecttwokindsof
edgesinanimage:
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

138/179

10/26/2016

DIPQuickGuide

Verticaldirection
Horizontaldirection

DifferencewithPrewittOperator:
The major difference is that in sobel operator the coefficients of masks are not fixed and
theycanbeadjustedaccordingtoourrequirementunlesstheydonotviolateanyproperty
ofderivativemasks.

FollowingistheverticalMaskofSobelOperator:
1

This mask works exactly same as the Prewitt operator vertical mask. There is only one
differencethatisithas2and2valuesincenteroffirstandthirdcolumn.Whenapplied
onanimagethismaskwillhighlighttheverticaledges.

Howitworks:
Whenweapplythismaskontheimageitprominentverticaledges.Itsimplyworkslikeas
firstorderderivateandcalculatesthedifferenceofpixelintensitiesinaedgeregion.
As the center column is of zero so it does not include the original values of an image but
rather it calculates the difference of right and left pixel values around that edge. Also the
centervaluesofboththefirstandthirdcolumnis2and2respectively.
This give more weight age to the pixel values around the edge region. This increase the
edgeintensityanditbecomeenhancedcomparativelytotheoriginalimage.

FollowingisthehorizontalMaskofSobelOperator:
1

Abovemaskwillfindedgesinhorizontaldirectionanditisbecausethatzeroscolumnisin
horizontal direction. When you will convolve this mask onto an image it would prominent
horizontaledgesintheimage.Theonlydifferencebetweenitisthatithave2and2asa
centerelementoffirstandthirdrow.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

139/179

10/26/2016

DIPQuickGuide

Howitworks:
Thismaskwillprominentthehorizontaledgesinanimage.Italsoworksontheprincipleof
above mask and calculates difference among the pixel intensities of a particular edge. As
thecenterrowofmaskisconsistofzerossoitdoesnotincludetheoriginalvaluesofedge
intheimagebutratheritcalculatethedifferenceofaboveandbelowpixelintensitiesofthe
particularedge.Thusincreasingthesuddenchangeofintensitiesandmakingtheedgemore
visible.
Nowitstimetoseethesemasksinaction:

SampleImage:
Followingisasamplepictureonwhichwewillapplyabovetwomasksoneattime.

AfterapplyingVerticalMask:
Afterapplyingverticalmaskontheabovesampleimage,followingimagewillbeobtained.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

140/179

10/26/2016

DIPQuickGuide

AfterapplyingHorizontalMask:
Afterapplyinghorizontalmaskontheabovesampleimage,followingimagewillbeobtained

Comparison:
As you can see that in the first picture on which we apply vertical mask, all the vertical
edges are more visible than the original image. Similarly in the second picture we have
appliedthehorizontalmaskandinresultallthehorizontaledgesarevisible.
Sointhiswayyoucanseethatwecandetectbothhorizontalandverticaledgesfroman
image.AlsoifyoucomparetheresultofsobeloperatorwithPrewittoperator,youwillfind
that sobel operator finds more edges or make edges more visible as compared to Prewitt
Operator.
This is because in sobel operator we have allotted more weight to the pixel intensities
aroundtheedges.

Applyingmoreweighttomask
Nowwecanalsoseethatifweapplymoreweighttothemask,themoreedgesitwillget
for us. Also as mentioned in the start of the tutorial that there is no fixed coefficients in
sobeloperator,sohereisanotherweightedoperator
1

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

141/179

10/26/2016

DIPQuickGuide

IfyoucancomparetheresultofthismaskwithofthePrewittverticalmask,itisclearthat
this mask will give out more edges as compared to Prewitt one just because we have
allottedmoreweightinthemask.

RobinsonCompassMask
Robinson compass masks are another type of derrivate mask which is used for edge
detection.Thisoperatorisalsoknownasdirectionmask.Inthisoperatorwetakeonemask
androtateitinallthe8compassmajordirectionsthatarefollowing:
North
NorthWest
West
SouthWest
South
SouthEast
East
NorthEast
Thereisnofixedmask.Youcantakeanymaskandyouhavetorotateittofindedgesinall
theabovementioneddirections.Allthemasksarerotatedonthebasesofdirectionofzero
columns.
For example lets see the following mask which is in North Direction and then rotate it to
makeallthedirectionmasks.

NorthDirectionMask
1

NorthWestDirectionMask
0

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

142/179

10/26/2016

DIPQuickGuide

WestDirectionMask
1

SouthWestDirectionMask
2

SouthDirectionMask
1

SouthEastDirectionMask
0

EastDirectionMask
1

NorthEastDirectionMask
2

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

143/179

10/26/2016

DIPQuickGuide

Asyoucanseethatallthedirectionsarecoveredonthebasisofzerosdirection.Eachmask
willgiveyoutheedgesonitsdirection.Nowletsseetheresultoftheentireabovemasks.
Suppose we have a sample picture from which we have to find all the edges. Here is our
samplepicture:

SamplePicture:

Nowwewillapplyalltheabovefiltersonthisimageandwegetthefollowingresult.

NorthDirectionEdges

NorthWestDirectionEdges

WestDirectionEdges

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

144/179

10/26/2016

DIPQuickGuide

SouthWestDirectionEdges

SouthDirectionEdges

SouthEastDirectionEdges

EastDirectionEdges

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

145/179

10/26/2016

DIPQuickGuide

NorthEastDirectionEdges

Asyoucanseethatbyapplyingalltheabovemasksyouwillgetedgesinallthedirection.
Result is also depends on the image. Suppose there is an image, which do not have any
NorthEastdirectionedgessothenthatmaskwillbeineffective.

KrischCompassMask
KirschCompassMaskisalsoaderivativemaskwhichisusedforfindingedges.Thisisalso
like Robinson compass find edges in all the eight directions of a compass. The only
differencebetweenRobinsonandkirschcompassmasksisthatinKirschwehaveastandard
maskbutinKirschwechangethemaskaccordingtoourownrequirements.
WiththehelpofKirschCompassMaskswecanfindedgesinthefollowingeightdirections.
North
NorthWest
West
SouthWest
South
SouthEast
East

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

146/179

10/26/2016

DIPQuickGuide

NorthEast
We take a standard mask which follows all the properties of a derivative mask and then
rotateittofindtheedges.
For example lets see the following mask which is in North Direction and then rotate it to
makeallthedirectionmasks.

NorthDirectionMask
3

NorthWestDirectionMask
3

WestDirectionMask

SouthWestDirectionMask
5

SouthDirectionMask
5

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

147/179

10/26/2016

DIPQuickGuide

SouthEastDirectionMask
3

EastDirectionMask

NorthEastDirectionMask

Asyoucanseethatallthedirectionsarecoveredandeachmaskwillgiveyoutheedgesof
its own direction. Now to help you better understand the concept of these masks we will
applyitonarealimage.Supposewehaveasamplepicturefromwhichwehavetofindall
theedges.Hereisoursamplepicture:

SamplePicture

Nowwewillapplyalltheabovefiltersonthisimageandwegetthefollowingresult.

NorthDirectionEdges

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

148/179

10/26/2016

DIPQuickGuide

NorthWestDirectionEdges

WestDirectionEdges

SouthWestDirectionEdges

SouthDirectionEdges

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

149/179

10/26/2016

DIPQuickGuide

SouthEastDirectionEdges

EastDirectionEdges

NorthEastDirectionEdges

Asyoucanseethatbyapplyingalltheabovemasksyouwillgetedgesinallthedirection.
Result is also depends on the image. Suppose there is an image, which do not have any
NorthEastdirectionedgessothenthatmaskwillbeineffective.

LaplacianOperator
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

150/179

LaplacianOperator

10/26/2016

DIPQuickGuide

LaplacianOperatorisalsoaderivativeoperatorwhichisusedtofindedgesinanimage.The
major difference between Laplacian and other operators like Prewitt, Sobel, Robinson and
Kirsch is that these all are first order derivative masks but Laplacian is a second order
derivativemask.InthismaskwehavetwofurtherclassificationsoneisPositiveLaplacian
OperatorandotherisNegativeLaplacianOperator.
Another difference between Laplacian and other operators is that unlike other operators
Laplaciandidnttakeoutedgesinanyparticulardirectionbutittakeoutedgesinfollowing
classification.
InwardEdges
OutwardEdges
LetsseethathowLaplacianoperatorworks.

PositiveLaplacianOperator:
InPositiveLaplacianwehavestandardmaskinwhichcenterelementofthemaskshouldbe
negativeandcornerelementsofmaskshouldbezero.
0

PositiveLaplacianOperatorisusetotakeoutoutwardedgesinanimage.

NegativeLaplacianOperator:
In negative Laplacian operator we also have a standard mask, in which center element
shouldbepositive.Alltheelementsinthecornershouldbezeroandrestofalltheelements
inthemaskshouldbe1.
0

NegativeLaplacianoperatorisusetotakeoutinwardedgesinanimage

Howitworks:
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

151/179

10/26/2016

DIPQuickGuide

Laplacian is a derivative operator its uses highlight gray level discontinuities in an image
and try to deemphasize regions with slowly varying gray levels. This operation in result
produces such images which have grayish edge lines and other discontinuities on a dark
background.Thisproducesinwardandoutwardedgesinanimage
Theimportantthingishowtoapplythesefiltersontoimage.Rememberwecantapplyboth
thepositiveandnegativeLaplacianoperatoronthesameimage.wehavetoapplyjustone
butthethingtorememberisthatifweapplypositiveLaplacianoperatorontheimagethen
we subtract the resultant image from the original image to get the sharpened image.
SimilarlyifweapplynegativeLaplacianoperatorthenwehavetoaddtheresultantimage
ontooriginalimagetogetthesharpenedimage.
Letsapplythesefiltersontoanimageandseehowitwillgetusinwardandoutwardedges
fromanimage.Supposewehaveafollowingsampleimage.

SampleImage

AfterapplyingPositiveLaplacianOperator:
AfterapplyingpositiveLaplacianoperatorwewillgetthefollowingimage.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

152/179

10/26/2016

DIPQuickGuide

AfterapplyingNegativeLaplacianOperator:
AfterapplyingnegativeLaplacianoperatorwewillgetthefollowingimage.

IntroductiontoFrequencydomain
We have deal with images in many domains. Now we are processing signals (images) in
frequencydomain.SincethisFourierseriesandfrequencydomainispurelymathematics,
sowewilltrytominimizethatmathspartandfocusmoreonitsuseinDIP.

Frequencydomainanalysis
Tillnow,allthedomainsinwhichwehaveanalyzedasignal,weanalyzeitwithrespectto
time. But in frequency domain we dont analyze signal with respect to time , but with
respectoffrequency.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

153/179

10/26/2016

DIPQuickGuide

Differencebetweenspatialdomainandfrequencydomain.
Inspatialdomain,wedealwithimagesasitis.Thevalueofthepixelsoftheimagechange
with respect to scene. Whereas in frequency domain , we deal with the rate at which the
pixelvaluesarechanginginspatialdomain.
Forsimplicity,Letsputitthisway.

Spatialdomain

In simple spatial domain , we directly deal with the image matrix. Whereas in frequency
domain,wedealanimagelikethis.

FrequencyDomain
We first transform the image to its frequency distribution. Then our black box system
performwhateverprocessingithastoperformed,andtheoutputoftheblackboxinthis
caseisnotanimage,butatransformation.Afterperforminginversetransformation,itis
convertedintoanimagewhichisthenviewedinspatialdomain.
Itcanbepictoriallyviewedas

Herewehaveusedthewordtransformation.Whatdoesitactuallymean?

Transformation.
A signal can be converted from time domain into frequency domain using mathematical
operatorscalledtransforms.Therearemanykindoftransformationthatdoesthis.Someof
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

154/179

10/26/2016

DIPQuickGuide

themaregivenbelow.
FourierSeries
Fouriertransformation
Laplacetransform
Ztransform
Outofallthese,wewillthoroughlydiscussFourierseriesandFouriertransformationinour
nexttutorial.

Frequencycomponents
Any image in spatial domain can be represented in a frequency domain. But what do this
frequenciesactuallymean.
Wewilldividefrequencycomponentsintotwomajorcomponents.

Highfrequencycomponents
Highfrequencycomponentscorrespondtoedgesinanimage.

Lowfrequencycomponents
Lowfrequencycomponentsinanimagecorrespondtosmoothregions.

FourierSeriesandTransform
In the last tutorial of Frequency domain analysis, we discussed that Fourier series and
Fouriertransformareusedtoconvertasignaltofrequencydomain.

Fourier
Fourier was a mathematician in 1822. He give Fourier series and Fourier transform to
convertasignalintofrequencydomain.

FourierSeries
Fourierseriessimplystatesthat,periodicsignalscanberepresentedintosumofsinesand
cosineswhenmultipliedwithacertainweight.Itfurtherstatesthatperiodicsignalscanbe
brokendownintofurthersignalswiththefollowingproperties.
Thesignalsaresinesandcosines
Thesignalsareharmonicsofeachother
Itcanbepictoriallyviewedas
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

155/179

10/26/2016

DIPQuickGuide

Intheabovesignal,thelastsignalisactuallythesumofalltheabovesignals.Thiswasthe
ideaoftheFourier.

Howitiscalculated.
Since as we have seen in the frequency domain , that in order to process an image in
frequencydomain,weneedtofirstconvertitusingintofrequencydomainandwehaveto
take inverse of the output to convert it back into spatial domain. Thats why both Fourier
series and Fourier transform has two formulas. One for conversion and one converting it
backtothespatialdomain.

Fourierseries
TheFourierseriescanbedenotedbythisformula.

Theinversecanbecalculatedbythisformula.

Fouriertransform
TheFouriertransformsimplystatesthatthatthenonperiodicsignalswhoseareaunderthe
curve is finite can also be represented into integrals of the sines and cosines after being
multipliedbyacertainweight.
The Fourier transform has many wide applications that include , image compression (e.g
JPEGcompression),filtreringandimageanalysis.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

156/179

10/26/2016

DIPQuickGuide

DifferencebetweenFourierseriesandtransform
AlthoughbothFourierseriesandFouriertransformaregivenbyFourier,butthedifference
betweenthemisFourierseriesisappliedonperiodicsignalsandFouriertransformisapplied
fornonperiodicsignals

Whichoneisappliedonimages.
Now the question is that which one is applied on the images , the Fourier series or the
Fouriertransform.Well,theanswertothisquestionliesinthefactthatwhatimagesare.
Imagesarenonperiodic.Andsincetheimagesarenonperiodic,soFouriertransformis
usedtoconvertthemintofrequencydomain.

Discretefouriertransform.
Sincewearedealingwithimages,andinfactdigitalimages,sofordigitalimageswewillbe
workingondiscretefouriertransform

ConsidertheaboveFouriertermofasinusoid.Itincludethreethings.
SpatialFrequency
Magnitude
Phase
Thespatialfrequencydirectlyrelateswiththebrightnessoftheimage.Themagnitudeofthe
sinusoiddirectlyrelateswiththecontrast.Contrastisthedifferencebetweenmaximumand
minimumpixelintensity.Phasecontainsthecolorinformation.
Theformulafor2dimensionaldiscreteFouriertransformisgivenbelow.

The discrete Fourier transform is actually the sampled Fourier transform, so it contains
somesamplesthatdenotesanimage.Intheaboveformulaf(x,y)denotestheimage,and
F(u,v) denotes the discrete Fourier transform. The formula for 2 dimensional inverse
discreteFouriertransformisgivenbelow.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

157/179

10/26/2016

DIPQuickGuide

TheinversediscreteFouriertransformconvertstheFouriertransformbacktotheimage

Considerthissignal.
Now we will see an image , whose we will calculate FFT magnitude spectrum and then
shiftedFFTmagnitudespectrumandthenwewilltakeLogofthatshiftedspectrum.

OriginalImage

TheFouriertransformmagnitudespectrum

TheShiftedFouriertransform

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

158/179

10/26/2016

DIPQuickGuide

TheShiftedMagnitudeSpectrum

ConvolutionTheorem
Inthelasttutorial,wediscussedabouttheimagesinfrequencydomain.Inthistutorial,we
are going to define a relationship between frequency domain and the images(spatial
domain).

Forexample:
Considerthisexample.

Thesameimageinthefrequencydomaincanberepresentedas.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

159/179

10/26/2016

DIPQuickGuide

Now whats the relationship between image or spatial domain and frequency domain. This
relationshipcanbeexplainedbyatheoremwhichiscalledasConvolutiontheorem.

ConvolutionTheorem
Therelationshipbetweenthespatialdomainandthefrequencydomaincanbeestablished
byconvolutiontheorem.
Theconvolutiontheoremcanberepresentedas.

Itcanbestatedastheconvolutioninspatialdomainisequaltofilteringinfrequencydomain
andviceversa.
Thefilteringinfrequencydomaincanberepresentedasfollowing:

Thestepsinfilteringaregivenbelow.
At first step we have to do some pre processing an image in spatial domain,
meansincreaseitscontrastorbrightness
ThenwewilltakediscreteFouriertransformoftheimage
Then we will center the discrete Fourier transform , as we will bring the discrete
Fouriertransformincenterfromcorners
Thenwewillapplyfiltering,meanswewillmultiplytheFouriertransformbyafilter
function
ThenwewillagainshifttheDFTfromcentertothecorners

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

160/179

10/26/2016

DIPQuickGuide

Last step would be take to inverse discrete Fourier transform , to bring the result
backfromfrequencydomaintospatialdomain
Andthisstepofpostprocessingisoptional,justlikepreprocessing,inwhichwe
justincreasetheappearanceofimage.

Filters
Theconceptoffilterinfrequencydomainissameastheconceptofamaskinconvolution.
Afterconvertinganimagetofrequencydomain,somefiltersareappliedinfilteringprocess
to perform different kind of processing on an image. The processing include blurring an
image,sharpeninganimagee.t.c.
Thecommontypeoffiltersforthesepurposesare:
Idealhighpassfilter
Ideallowpassfilter
Gaussianhighpassfilter
Gaussianlowpassfilter
Inthenexttutorial,wewilldiscussaboutfilterindetail.

HighPassvsLowPassFilters
Inthelasttutorial,webrieflydiscussaboutfilters.Inthistutorialwewillthoroughlydiscuss
aboutthem.Beforediscussingaboutletstalkaboutmasksfirst.Theconceptofmaskhas
beendiscussedinourtutorialofconvolutionandmasks.

Blurringmasksvsderivativemasks.
Wearegoingtoperformacomparisonbetweenblurringmasksandderivativemasks.

Blurringmasks:
Ablurringmaskhasthefollowingproperties.
Allthevaluesinblurringmasksarepositive
Thesumofallthevaluesisequalto1
Theedgecontentisreducedbyusingablurringmask
Asthesizeofthemaskgrow,moresmoothingeffectwilltakeplace
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

161/179

10/26/2016

DIPQuickGuide

Derrivativemasks:
Aderivativemaskhasthefollowingproperties.
Aderivativemaskhavepositiveandaswellasnegativevalues
Thesumofallthevaluesinaderivativemaskisequaltozero
Theedgecontentisincreasedbyaderivativemask
Asthesizeofthemaskgrows,moreedgecontentisincreased

Relationshipbetweenblurringmaskandderivativemaskwithhighpass
filtersandlowpassfilters.
Therelationshipbetweenblurringmaskandderivativemaskwithahighpassfilterandlow
passfiltercanbedefinedsimplyas.
Blurringmasksarealsocalledaslowpassfilter
Derivativemasksarealsocalledashighpassfilter

HighpassfrequencycomponentsandLowpassfrequencycomponents
The high pass frequency components denotes edges whereas the low pass frequency
componentsdenotessmoothregions.

IdeallowpassandIdealHighpassfilters
Thisisthecommonexampleoflowpassfilter.

Whenoneisplacedinsideandthezeroisplacedoutside,wegotablurredimage.Nowas
we increase the size of 1, blurring would be increased and the edge content would be
reduced.
Thisisacommonexampleofhighpassfilter.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

162/179

10/26/2016

DIPQuickGuide

When0isplacedinside,wegetedges,whichgivesusasketchedimage.Anideallowpass
filterinfrequencydomainisgivenbelow

Theideallowpassfiltercanbegraphicallyrepresentedas

Nowletsapplythisfiltertoanactualimageandletsseewhatwegot.

Sampleimage.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

163/179

10/26/2016

DIPQuickGuide

Imageinfrequencydomain

Applyingfilteroverthisimage

ResultantImage

Withthesameway,anidealhighpassfiltercanbeappliedonanimage.Butobviouslythe
results would be different as , the low pass reduces the edged content and the high pass
increaseit.
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

164/179

10/26/2016

DIPQuickGuide

GaussianLowpassandGaussianHighpassfilter
Gaussian low pass and Gaussian high pass filter minimize the problem that occur in ideal
lowpassandhighpassfilter.
This problem is known as ringing effect. This is due to reason because at some points
transition between one color to the other cannot be defined precisely, due to which the
ringingeffectappearsatthatpoint.
Havealookatthisgraph.

Thisistherepresentationofideallowpassfilter.NowattheexactpointofDo,youcannot
tellthatthevaluewouldbe0or1.Duetowhichtheringingeffectappearsatthatpoint.
Soinordertoreducetheeffectthatappearsisideallowpassandidealhighpassfilter,the
followingGaussianlowpassfilterandGaussianhighpassfilterisintroduced.

GaussianLowpassfilter
The concept of filtering and low pass remains the same, but only the transition becomes
differentandbecomemoresmooth.
TheGaussianlowpassfiltercanberepresentedas

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

165/179

10/26/2016

DIPQuickGuide

Note the smooth curve transition, due to which at each point, the value of Do , can be
exactlydefined.

Gaussianhighpassfilter
Gaussian high pass filter has the same concept as ideal high pass filter , but again the
transitionismoresmoothascomparedtotheidealone.

IntroductiontoColorSpaces
Inthistutorial,wearegoingtotalkaboutcolorspaces.

Whatarecolorspaces?
Colorspacesaredifferenttypesofcolormodes,usedinimageprocessingandsignalsand
systemforvariouspurposes.Someofthecommoncolorspacesare:
RGB
CMYK
YUV
YIQ
YCbCr
HSV

RGB

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

166/179

10/26/2016

DIPQuickGuide

RGB is the most widely used color space , and we have already discussed it in the past
tutorials.RGBstandsforredgreenandblue.
WhatRGBmodelstates,thateachcolorimageisactuallyformedofthreedifferentimages.
Redimage,Blueimage,andblackimage.Anormalgrayscaleimagecanbedefinedbyonly
onematrix,butacolorimageisactuallycomposedofthreedifferentmatrices.
Onecolorimagematrix=redmatrix+bluematrix+greenmatrix
Thiscanbebestseeninthisexamplebelow.

ApplicationsofRGB
ThecommonapplicationsofRGBmodelare
Cathoderaytube(CRT)
Liquidcrystaldisplay(LCD)
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

167/179

10/26/2016

DIPQuickGuide

PlasmaDisplayorLEDdisplaysuchasatelevision
Acomputemonitororalargescalescreen

CMYK

RGBtoCMYconversion
TheconversionfromRGBtoCMYisdoneusingthismethod.

Consideryouhaveancolorimage,meansyouhavethreedifferentarraysofRED,GREEN
andBLUE.NowifyouwanttoconvertitintoCMY,hereswhatyouhavetodo.Youhaveto
subtract it by the maximum number of levels 1. Each matrix is subtracted and its
respectiveCMYmatrixisfilledwithresult.

YUV
YUV defines a color space in terms of one luma (Y) and two chrominance (UV)
components.TheYUVcolormodelisusedinthefollowingcompositecolorvideostandards.
NTSC(NationalTelevisionSystemCommittee)
PAL(PhaseAlternatingLine)
SECAM(Sequentialcouleuraamemoire,Frenchforsequentialcolorwithmemory)

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

168/179

10/26/2016

DIPQuickGuide

YCbCr
YCbCrcolormodelcontainsY,thelumacomponentandcbandcrarethebluediffernece
andreddifferencechromacomponents.
Itisnotanabsolutecolorspace.Itismainlyusedfordigitalsystems
ItscommonapplicationsincludeJPEGandMPEGcompression.
YUV is often used as the term for YCbCr, however they are totally different formats. The
maindifferencebetweenthesetwoisthattheformerisanalogwhilethelaterisdigital.

IntroductiontoJPEGCompression

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

169/179

10/26/2016

DIPQuickGuide

IntroductiontoJPEGCompression
In our last tutorial of image compression , we discuss some of the techniques used for
compression
WearegoingtodiscussJPEGcompressionwhichislossycompression,assomedataisloss
intheend.
Letsdiscussfirstwhatimagecompressionis.

Imagecompression
Imagecompressionisthemethodofdatacompressionondigitalimages.
Themainobjectiveintheimagecompressionis:
Storedatainanefficientform
Transmitdatainanefficientform
Imagecompressioncanbelossyorlossless.

JPEGcompression
JPEG stands for Joint photographic experts group. It is the first interanational standard in
imagecompression.Itiswidelyusedtoday.Itcouldbelossyaswellaslossless.Butthe
techniquewearegoingtodiscussheretodayislossycompressiontechnique.

Howjpegcompressionworks:
Firststepistodivideanimageintoblockswitheachhavingdimensionsof8x8.

Letsfortherecord,saythatthis8x8imagecontainsthefollowingvalues.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

170/179

10/26/2016

DIPQuickGuide

Therangeofthepixelsintensitiesnowarefrom0to255.Wewillchangetherangefrom
128to127.
Subtracting128fromeachpixelvalueyieldspixelvaluefrom128to127.Aftersubtracting
128fromeachofthepixelvalue,wegotthefollowingresults.

Nowwewillcomputeusingthisformula.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

171/179

10/26/2016

DIPQuickGuide

TheresultcomesfromthisisstoredinletssayA(j,k)matrix.
ThereisastandardmatrixthatisusedforcomputingJPEGcompression,whichisgivenbya
matrixcalledasLuminancematrix.
Thismatrixisgivenbelow

Applyingthefollowingformula

Wegotthisresultafterapplying.

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

172/179

10/26/2016

DIPQuickGuide

Now we will perform the real trick which is done in JPEG compression which is ZIGZAG
movement.Thezigzagsequencefortheabovematrixisshownbelow.Youhavetoperform
zigzaguntilyoufindallzeroesahead.Henceourimageisnowcompressed.

SummarizingJPEGcompression
ThefirststepistoconvertanimagetoYCbCrandjustpicktheYchannelandbreakinto8
x8blocks.Thenstartingfromthefirstblock,maptherangefrom128to127.Afterthat
you have to find the discrete fourier transform of the matrix. The result of this should be
quantized.Thelaststepistoapplyencodinginthezigzagmanneranddoittillyoufindall
zero.
Savethisonedimensionalarrayandyouaredone.
Note.Youhavetorepeatthisprocedureforalltheblockof8x8.

OpticalCharacterRecognition
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

173/179

10/26/2016

DIPQuickGuide

OpticalcharacterrecognitionisusuallyabbreviatedasOCR.Itincludesthemechanicaland
electricalconversionofscannedimagesofhandwritten,typewrittentextintomachinetext.
Itiscommonmethodofdigitizingprintedtextssothattheycanbeelectronicallysearched,
storedmorecompactly,displayedonline,andusedinmachineprocessessuchasmachine
translation,texttospeechandtextmining.
In recent years, OCR (Optical Character Recognition) technology has been applied
throughout the entire spectrum of industries, revolutionizing the document management
process. OCR has enabled scanned documents to become more than just image files,
turningintofullysearchabledocumentswithtextcontentthatisrecognizedbycomputers.
WiththehelpofOCR,peoplenolongerneedtomanuallyretypeimportantdocumentswhen
entering them into electronic databases. Instead, OCR extracts relevant information and
entersitautomatically.Theresultisaccurate,efficientinformationprocessinginlesstime.
Opticalcharacterrecognitionhasmultipleresearchareasbutthemostcommonareasare
asfollowing:

Banking:
he uses of OCR vary across different fields. One widely known application is in banking,
whereOCRisusedtoprocesscheckswithouthumaninvolvement.Acheckcanbeinserted
intoamachine,thewritingonitisscannedinstantly,andthecorrectamountofmoneyis
transferred. This technology has nearly been perfected for printed checks, and is fairly
accurate for handwritten checks as well, though it occasionally requires manual
confirmation.Overall,thisreduceswaittimesinmanybanks.

Blindandvisuallyimpairedpersons:
OneofthemajorfactorsinthebeginningofresearchbehindtheOCRisthatscientistwant
tomakeacomputerordevicewhichcouldreadbooktotheblindpeopleoutloud.Onthis
researchscientistmadeflatbedscannerwhichismostcommonlyknowntousasdocument
scanner.

Legaldepartment:
In the legal industry, there has also been a significant movement to digitize paper
documents. In order to save space and eliminate the need to sift through boxes of paper
files, documents are being scanned and entered into computer databases. OCR further
simplifies the process by making documents textsearchable, so that they are easier to
locateandworkwithonceinthedatabase.Legalprofessionalsnowhavefast,easyaccess
toahugelibraryofdocumentsinelectronicformat,whichtheycanfindsimplybytypingina
fewkeywords.

RetailIndustry:
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

174/179

10/26/2016

DIPQuickGuide

BarcoderecognitiontechnologyisalsorelatedtoOCR.Weseetheuseofthistechnologyin
ourcommondayuse.

OtherUses:
OCR is widely used in many other fields, including education, finance, and government
agencies. OCR has made countless texts available online, saving money for students and
allowingknowledgetobeshared.Invoiceimagingapplicationsareusedinmanybusinesses
to keep track of financial records and prevent a backlog of payments from piling up. In
government agencies and independent organizations, OCR simplifies data collection and
analysis,amongotherprocesses.Asthetechnologycontinuestodevelop,moreandmore
applications are found for OCR technology, including increased use of handwriting
recognition.

ComputerVisionandComputerGraphics
ComputerVision
Computer vision is concerned with modeling and replicating human vision using computer
software and hardware. Formally if we define computer vision then its definition would be
thatcomputervisionisadisciplinethatstudieshowtoreconstruct,interruptandunderstand
a3dscenefromits2dimagesintermsofthepropertiesofthestructurepresentinscene.
It needs knowledge from the following fields in order to understand and stimulate the
operationofhumanvisionsystem.
ComputerScience
ElectricalEngineering
Mathematics
Physiology
Biology
CognitiveScience

ComputerVisionHierarchy:
Computervisionisdividedintothreebasiccategoriesthatareasfollowing:
Lowlevelvision:includesprocessimageforfeatureextraction.
Intermediatelevelvision:includesobjectrecognitionand3DsceneInterpretation

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

175/179

10/26/2016

DIPQuickGuide

Highlevel vision: includes conceptual description of a scene like activity, intention and
behavior.

RelatedFields:
ComputerVisionoverlapssignificantlywiththefollowingfields:
ImageProcessing:itfocusesonimagemanipulation.
PatternRecognition:itstudiesvarioustechniquestoclassifypatterns.
Photogrammetry:itisconcernedwithobtainingaccuratemeasurementsfromimages.

ComputerVisionVsImageProcessing:
Image processing studies image to image transformation. The input and output of image
processingarebothimages.
Computer vision is the construction of explicit, meaningful descriptions of physical objects
from their image. The output of computer vision is a description or an interpretation of
structuresin3Dscene.

ExampleApplications:
Robotics
Medicine
Security
Transportation
IndustrialAutomation

RoboticsApplication:
Localizationdeterminerobotlocationautomatically
Navigation
Obstaclesavoidance
Assembly(peginhole,welding,painting)
Manipulation(e.g.PUMArobotmanipulator)
Human Robot Interaction (HRI): Intelligent robotics to interact with and serve
people
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

176/179

10/26/2016

DIPQuickGuide

MedicineApplication:
Classificationanddetection(e.g.lesionorcellsclassificationandtumordetection)
2D/3Dsegmentation
3Dhumanorganreconstruction(MRIorultrasound)
Visionguidedroboticssurgery

IndustrialAutomationApplication:
Industrialinspection(defectdetection)
Assembly
Barcodeandpackagelabelreading
Objectsorting
Documentunderstanding(e.g.OCR)

SecurityApplication:
Biometrics(iris,fingerprint,facerecognition)
Surveillancedetectingcertainsuspiciousactivitiesorbehaviors

TransportationApplication:
Autonomousvehicle
Safety,e.g.,drivervigilancemonitoring

ComputerGraphics
Computer graphics are graphics created using computers and the representation of image
data by a computer specifically with help from specialized graphic hardware and software.
Formally we can say that Computer graphics is creation, manipulation and storage of
geometricobjects(modeling)andtheirimages(Rendering).
The field of computer graphics developed with the emergence of computer graphics
hardware.Todaycomputergraphicsisuseinalmosteveryfield.Manypowerfultoolshave
been developed to visualize data. Computer graphics field become more popular when
companiesstartedusingitinvideogames.Todayitisamultibilliondollarindustryandmain
drivingforcebehindthecomputergraphicsdevelopment.Somecommonapplicationsareas
areasfollowing:
https://www.tutorialspoint.com/dip/dip_quick_guide.htm

177/179

10/26/2016

DIPQuickGuide

ComputerAidedDesign(CAD)
PresentationGraphics
3dAnimation
Educationandtraining
GraphicalUserInterfaces

ComputerAidedDesign:
Usedindesignofbuildings,automobiles,aircraftandmanyotherproduct
Usetomakevirtualrealitysystem.

PresentationGraphics:
Commonlyusedtosummarizefinancial,statisticaldata
Usetogenerateslides

3dAnimation:
UsedheavilyinthemovieindustrybycompaniessuchasPixar,DresmsWorks
Toaddspecialeffectsingamesandmovies.

Educationandtraining:
Computergeneratedmodelsofphysicalsystems
MedicalVisualization
3DMRI
Dentalandbonescans
Stimulatorsfortrainingofpilotsetc.

GraphicalUserInterfaces:
It is used to make graphical user interfaces objects like buttons, icons and other
components

PreviousPage

NextPage
Advertisements

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

178/179

10/26/2016

DIPQuickGuide

Write for us

FAQ's

Helping

Contact

Copyright 2016. All Rights Reserved.


Enter email for newsletter

https://www.tutorialspoint.com/dip/dip_quick_guide.htm

go

179/179

Das könnte Ihnen auch gefallen