Introduction To Digital image Processing

MohamedFathy132015 37 views 25 slides May 26, 2024
Slide 1
Slide 1 of 25
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25

About This Presentation

Image Processing


Slide Content

Computer
Science
1

Digital Image ProcessingSection (4)
A. H. Seddik 2
Assignment #1

Digital Image ProcessingSection (4)
A. H. Seddik 3
Assignment #2

Digital Image ProcessingSection (4)
1-Write a MatLabFunctionthat transposesimage.
Lab Assignments :-
A. H. Seddik 4
2-Write a MatLabFunctionthat Flipsimage Vertically.
3-Write a MatLabFunctionthat Obtains negativeversion of the image.

Digital Image ProcessingSection (4)
Cropping Image
A. H. Seddik 5

Digital Image ProcessingSection (4)
MatLabScripts
A. H. Seddik 6
Code in Command Window

Digital Image ProcessingSection (4)
MatLabFunctions
A. H. Seddik 7

Computer
Science
8

Digital Image Processing
Concept Of Zooming
Section (4)
InthisLecturewearegoingtointroducetheconceptofzooming,andthecommontechniquesthat
areusedtozoomanimage.
Zooming
Zoomingsimplymeansenlargingapictureinasensethatthedetailsintheimagebecamemore
visibleandclear.Zoominganimagehasmanywideapplicationsrangingfromzoomingthrougha
cameralens,tozoomanimageoninternete.t.c.
A. H. Seddik 9
Forexample

Digital Image ProcessingSection (4)
Youcanzoomsomethingattwodifferentsteps:
Thefirststepincludeszoomingbeforetakinganparticularimage.Thisisknownaspreprocessing
zoom.Thiszoominvolveshardwareandmechanicalmovement.
Thesecondstepistozoomonceanimagehasbeencaptured.Itisdonethroughmanydifferent
algorithmsinwhichwemanipulatepixelstozoomintherequiredportion.Wewilldiscussthemin
detailsnext.
OpticalZoomvsdigitalZoom
Thesetwotypesofzoomaresupportedbythecameras.
A. H. Seddik 10
OpticalZoom:
1.Theopticalzoomisachievedusingthemovementofthelensofyourcamera.Anopticalzoomis
actuallyatruezoom.
2.Theresultoftheopticalzoomisfarbetterthenthatofdigitalzoom.Inopticalzoom,an
imageismagnifiedbythelensinsuchawaythattheobjectsintheimageappeartobecloser
tothecamera.
3.Inopticalzoomthelensisphysicallyextendtozoomormagnifyanobject.

Digital Image ProcessingSection (4)
DigitalZoom:
Digitalzoomisbasicallyimageprocessingwithinacamera.Duringadigitalzoom,thecenterofthe
imageismagnifiedandtheedgesofthepicturegotcropout.Duetomagnifiedcenter,itlookslike
thattheobjectisclosertoyou.
Duringadigitalzoom,thepixelsgotexpand,duetowhichthequalityoftheimageiscompromised.
Thesameeffectofdigitalzoomcanbeseenaftertheimageistakenthroughyourcomputerbyusing
animageprocessingtoolbox/software,suchasPhotoshop.
A. H. Seddik 11
Thefollowingpictureistheresultofdigitalzoomdonethrough
oneofthefollowingmethodsgivenbelowinthezooming
methods.
Nowsincewearelearningdigitalimageprocessing,wewillnot
focus,onhowanimagecanbezoomedopticallyusinglensor
otherstuff.Ratherwewillfocusonthemethods,thatenableto
zoomadigitalimage.

Digital Image ProcessingSection (4)
Zoomingmethods:
Althoughtherearemanymethodsthatdoesthisjob,butwearegoingtodiscussthemost
commonofthemhere.
Theyarelistedbelow:
A. H. Seddik 12
1.Pixelreplicationor(Nearestneighborinterpolation)
2.Zeroorderholdmethod
3.ZoomingKtimes
Eachofthemethodshasitsownadvantagesanddisadvantages.Wewillstartbydiscussingpixel
replication.

Digital Image ProcessingSection (4)
Method 1: Pixel replication
Introduction:
A. H. Seddik 13
ItisalsoknownasNearestneighborinterpolation.Asitsnamesuggest,inthismethod,wejust
replicatetheneighboringpixels.Inthismethod,zoomingisnothingbutincreaseamountofpixels.
Thisalgorithmworksonthesameprinciple.
Working:
Inthismethodwecreatenewpixelsformthealreadygivenpixels.Eachpixelisreplicatedinthis
methodntimesrowwiseandcolumnwiseandyougotazoomedimage.Itsassimpleasthat.
Forexample:
ifyouhaveanimageof2rowsand2columnsandyouwanttozoomittwiceor2timesusingpixel
replication,herehowitcanbedone.
Forabetterunderstanding,theimagehasbeentakenintheformofmatrixwiththepixelvaluesof
theimage.

Digital Image ProcessingSection (4)
A. H. Seddik 14
Theaboveimagehastworowsandtwocolumns,wewillfirstzoomitrowwise.
Rowwisezooming:
Whenwezoomitrowwise,wewilljustsimplecopytherowspixelstoitsadjacentnewcell.
Herehowitwouldbedone.
21
43
2211
4433
Asyoucanthatintheabovematrix,eachpixelisreplicatedtwiceintherows.

Digital Image ProcessingSection (4)
A. H. Seddik 15
Columnwisezooming:
Thenextstepistoreplicateeachofthepixelcolumnwise,thatwewillsimplycopythecolumnpixel
toitsadjacentnewcolumnorsimplybelowit.
Herehowitwouldbedone.
2211
4433
2211
2211
4433
4433

Digital Image ProcessingSection (4)
A. H. Seddik 16
Newimagesize
Asitcanbeseenfromtheaboveexample,thatanoriginalimageof2rowsand2columnshasbeen
convertedinto4rowsand4columnsafterzooming.Thatmeansthenewimagehasadimensionsof
(Original image rows * zooming factor, Original Image cols * zooming factor)
Oneoftheadvantageofthiszoomingtechniqueis,itisverysimple.Youjusthavetocopythe
pixelsandnothingelse.
Thedisadvantageofthistechniqueisthatimagegotzoomedbuttheoutputisveryblurry.Andas
thezoomingfactorincreased,theimagegotmoreandmoreblurred.Thatwouldeventually
resultinfullyblurredimage.
Advantageanddisadvantage:

Digital Image ProcessingSection (4)
Method 2: Zero order hold
Introduction:
A. H. Seddik 17
Zeroorderholdmethodisanothermethodofzooming.Itisalsoknownaszoomtwice.Becauseit
canonlyzoomtwice.Wewillseeinthebelowexamplethatwhyitdoesthat.
Working:
Inzeroorderholdmethod,wepicktwoadjacentelementsfromtherowsrespectivelyandthenwe
addthemanddividetheresultbytwo,andplacetheirresultinbetweenthosetwoelements.Wefirst
dothisrowwiseandthenwedothiscolumnwise.
Forexample:
Letstakeanimageofthedimensionsof2rowsand2columnsandzoomittwiceusingzeroorder
hold.
21
43
Firstwewillzoomitrowwiseandthencolumnwise.

Digital Image ProcessingSection (4)
A. H. Seddik 18
Rowwisezooming:
211
433
Aswetakethefirsttwonumbers:(2+1)=3andthenwedivideitby2,weget1.5whichis
approximatedto1.Thesamemethodisappliedintherow2.
Columnwisezooming:
211
322
433
Wetaketwoadjacentcolumnpixelvalueswhichare1and3.Weaddthemandgot4.4isthen
dividedby2andweget2whichisplacedinbetweenthem.Thesamemethodisappliedinallthe
columns.

Digital Image ProcessingSection (4)
A. H. Seddik 19
Newimagesize
Asyoucanseethatthedimensionsofthenewimageare3x3wheretheoriginalimagedimensions
are2x2.Soitmeansthatthedimensionsofthenewimagearebasedonthefollowingformula
(2(number of rows) -1) X (2(number of columns) -1)
Oneoftheadvantageofthiszoomingtechnique,thatitdoesnotcreateasblurrypictureas
comparetothenearestneighborinterpolationmethod.Butitalsohasadisadvantagethatitcanonly
runonthepowerof2.Itcanbedemonstratedhere.
Advantageanddisadvantage:
Considertheaboveimageof2rowsand2columns.Ifwehavetozoomit6times,usingzeroorder
holdmethod,wecannotdoit.Astheformulashowsusthis.Itcouldonlyzoominthepowerof2-
2,4,8,16,32andsoon.
Evenifyoutrytozoomit,youcannot.Becauseatfirstwhenyouwillzoomittwotimes,andtheresult
wouldbesameasshowninthecolumnwisezoomingwithdimensionsequalto3x3.Thenyouwill
zoomitagainandyouwillgetdimensionsequalto5x5.Nowifyouwilldoitagain,youwillget
dimensionsequalto9x9.
Reasonbehindtwicezooming:

Digital Image ProcessingSection (4)
Method 3: K-Times zooming
Introduction:
A. H. Seddik 20
Ktimesisthethirdzoomingmethodwearegoingtodiscuss.Itisoneofthemostperfectzooming
algorithmdiscussedsofar.Itcatersthechallengesofbothtwicezoomingandpixelreplication.Kin
thiszoomingalgorithmstandsforzoomingfactor.
Working:
Itworkslikethisway.
Firstofall,youhavetotaketwoadjacentpixelsasyoudidinthezoomingtwice.Thenyouhaveto
subtractthesmallerfromthegreaterone.Wecallthisoutput(OP).
Dividetheoutput(OP)withthezoomingfactor(K).Nowyouhavetoaddtheresulttothesmallervalue
andputtheresultinbetweenthosetwovalues.
AddthevalueOPagaintothevalueyoujustputandplaceitagainnexttothepreviousputtedvalue.
Youhavetodoittillyouplacek-1valuesinit.
Repeatthesamestepforalltherowsandthecolumns,andyougetazoomedimages.

Digital Image ProcessingSection (4)
For example:
A. H. Seddik 21
Supposeyouhaveanimageof2rowsand3columns,whichisgivenbelow.Andyouhavetozoomit
threetimes.
RowWiseZooming:
Kinthiscaseis3.K=3.
Thenumberofvaluesthatshouldbeinsertedisk-1=3-1=2.
153015
301530
1.Takethefirsttwoadjacentpixels.Whichare15and30.
2.Subtract15from30.30-15=15.
3.Divide15byk.15/k=15/3=5.WecallitOP.(whereopisjustaname)
4.AddOPtolowernumber.15+OP=15+5=20.
5.AddOPto20again.20+OP=20+5=25.
6.Wedothat2timesbecausewehavetoinsertk-1values.
7.Nowrepeatthisstepforthenexttwoadjacentpixels.Itisshowninthefirsttable.
8.Afterinsertingthevalues,youhavetosorttheinsertedvalues,sothereremainsasymmetry
betweenthem.Itisshowninthesecondtable

Digital Image ProcessingSection (4)
Table 1.
A. H. Seddik 22
15252030252015
30252015252030
Table 2.
15202530252015
30252015202530

Digital Image ProcessingSection (4)
Column wise zooming
A. H. Seddik 23
Thesameprocedurehastobeperformedcolumnwise.Theprocedureincludetakingthetwo
adjacentpixelvalues,andthensubtractingthesmallerfromthebiggerone.Thenafterthat,youhave
todivideitbyk.StoretheresultasOP.AddOPtosmallerone,andthenagainaddOPtothevalue
thatcomesinfirstadditionofOP.Insertthenewvalues.
Here what you got after all that.
15202530252015
20212125212120
25222220222225
30252015202530

Digital Image ProcessingSection (4)
A. H. Seddik 24
Newimagesize
Thebestwaytocalculatetheformulaforthedimensionsofanewimageistocomparethe
dimensionsoftheoriginalimageandthefinalimage.Thedimensionsoftheoriginalimagewere2X
3.Andthedimensionsofthenewimageare4x7.Theformulathusis:
(K (number of rows -1) + 1) X (K (number of cols -1) + 1)
Theoneoftheclearadvantagethatktimezoomingalgorithmhasthatitisabletocomputezoomof
anyfactorwhichwasthepowerofpixelreplicationalgorithm,alsoitgivesimprovedresult(less
blurry)whichwasthepowerofzeroorderholdmethod.SohenceItcomprisesthepowerofthe
twoalgorithms.
Theonlydifficultythisalgorithmhasthatithastobesortintheend,whichisanadditional
step,andthusincreasesthecostofcomputation.
Advantageanddisadvantage:

Computer
Science
25
Tags