DigitalImageProcessingComputerProjectReportIVContrastEnhancement,HistogramEqualization,SpatialFiltering,&EdgeDetectionStudentID:20091613310032Name:XiaopengJiDate:April13,20121A.Objectivesi.Studytheeffectsofcontrastenhancementhistogramequalizationandhistogramstretching.ii.StudytheeffectsofhistogramequalizationviaHISTEQfunction.iii.UtilizingtheSUBPLOTfunctiontodisplayimages.iv.StudytheeffectsofspatialfilteringusingIMNOISE,FSPECIAL,andMEDFILT2functions.v.Studyimagenoiseandhowthemedianandaveragefiltersremovenoise.vi.Studydifferentmethodsofedgedetectionforuseonnoisyimagesspecificallymotionblur,GaussiannoiseandfilteredGaussiannoiseviaaveraging.vii.Formulatereal-worldapplicationswhichutilizetheabovefunctionsandconcepts.B.MethodsThisprojectwillutilizethefunctionsofMATLABImageProcessingToolboxtoperformContrastEnhancement,HistogramEqualization,SpatialFilteringusingaveragingandmedianfilters,andanEdgedetectionalgorithmexperiment.1.IMRESIZEfunctionutilizationforimageexpansion.2.ContraststretchingusingIMADJUSTandSTRETCHLIMfunctions.3.HistogramequalizationusingHISTEQfunction.4.DatadisplayutilizingSUBPLOTfunction.5.SpatialfilteringusingIMNOISE,FSPECIAL,andMEDFILT2.6.EdgedetectiononnoisyimagesusingMatlabnoiseandedgedetectionfunctions.C.Results21.LoadimagesaltAndPepper.gifandusetheIMRESIZEfunctiontointerpolatebyafactorof4using‘bi-cubic’interpolation.Atthecommandpromptenter:saltandpepper_filename='saltAndPepper.gif';saltandpepper_image=imread(saltandpepper_filename);picture_saltandpepper_scale=imresize(saltandpepper_image,[60*459*4],'bicubic');imwrite(picture_saltandpepper_scale,'saltandpepper_bicubic.jpg','jpg');Theoriginalimage,saltAndPepper.gif,wasspatiallyexpanded4xineachdimensionusingbi-cubicinterpolation.TheIMRESIZEfunctionwasutilizedtoperformtheoperation.Figure1:Originalimage.Figure2:saltAndPepper.gifspatiallyexpandedby4x.2.ContrastStretching–UsetheMATLABfunctionIMADJUSTtoperformthecontraststretch.a)Useimadjust(Image,[LOW_IN,HIGH_IN],[]);inthisformat.[LOW_IN,HIGH_IN]mustbeinthe[0,1]rangesothevectormustbescaledbythemaximumgraylevelthattheimageisquantizedto(i.e.8-bitsa256graylevels).3Atthecommandpromptenter:saltandpepper_imadjust=imadjust(picture_saltandpepper_cale,[0(180/255)],[]);imwrite(saltandpepper_imadjust,'saltandpepper_imadjust.jpg','jpg');Figure3:Adjustedfigure2suchthatthelowestandhighestintensitiesare0and255respectively.b)Computethemeangraylevel(function:MEAN2)andthestandarddeviation(function:STD2)anddesignamappingfunctionforLOW_INandHIGH_INbasedonthefollowingequations:LOW_IN=(mean-(standarddeviation)/2)/256HIGH_IN=(mean+(standarddeviation)/2)/256Atthecommandpromptenter:saltandpepper_mean=mean2(picture_saltandpepper_scale)saltandpepper_std=std2(picture_saltandpepper_scale)low_in=(saltandpepper_mean-(saltandpepper_std)/2)/256high_in=(saltandpepper_mean+(saltandpepper_std)/2)/256saltandpepper_mean=imadjust(picture_saltandpepper_scale,[low_inhigh_in],[]);imwrite(saltandpepper_mean,'saltandpepper_mean.jpg','j4pg');Figure2:Thehistogramofcameraman.tifsaltandpepper_mean=60.8439saltandpepper_std=30.3702low_in=0.1784high_in=0.2970Figure4:IMADJUSTperformedonFigure2withLOW_INandHIGH_INequaltoabovecalculationsc)UsethefunctionSTRETCHLIMtocomputethetolerancefortheIMADJUSTfunction.ThefunctionSTRETCHLIMwillcomputeavectorcorrespondingto[LOW_IN,HIGH_IN].UsethevectorcalculatedbySTRETCHLIMtointheIMADJUSTfunctiondescribedina.)andcomputetheimagetransformation.Atthecommandpromptenter:low_high=stretchlim(picture_saltandpepper_scale,0)saltandpepper_stretchlim=imadjust(picture_saltandpepper_scale,low_high,[]);imwrite(saltandpepper_stretchlim,5'saltandpepper_stretchlim.jpg','jpg');low_high=(00.7059)Figure5:STRETCHLIMperformedwithIMADJUSTonFigure23.HistogramEqualization–UsethefunctionHISTEQtocomputethehistogramequalizationoftheoriginalimage.4.DataDisplay–UsetheSUBPLOTcommandtodisplayyourresults.Atthecommandpromptenter:imhist(picture_saltandpepper_scale);saltandpepper_EqualizedImage=histeq(picture_saltandpepper_scale);imwrite(saltandpepper_EqualizedImage,'saltandpepper_EqualizedImage.jpg','jpg');colormap('gray');subplot(2,2,1);image(picture_saltandpepper_scale);title('OriginalImage');subplot(2,2,2);6image(saltandpepper_mean);title('MeanandStdImage');subplot(2,2,3);image(saltandpepper_stretchlim);title('StretchLimImage');subplot(2,2,4);image(saltandpepper_EqualizedImage);title('EqualizedImage');figure;subplot(2,2,1);imhist(picture_saltandpepper_scale);title('OriginalImage');subplot(2,2,2);imhist(saltandpepper_mean);title('MeanandStdImage');subplot(2,2,3);imhist(saltandpepper_stretchlim);title('StretchLimImage');subplot(2,2,4);imhist(saltandpepper_EqualizedImage);title('EqualizedImage');7Figure3:Afterhistogramequalization85.SpatialFiltering–UsethefunctionsIMNOISE,FSPECIAL,andMEDFILT2toperformspatialfilteringofnoisecorruptedimages.a)Usingthehistogramequalizedimageof3)usetheIMNOISEfunctiontogeneratetwonoisecorruptedimages.noise_gaussian=imnoise(Image,’gaussian’,0,0.05);noise_saltAndpepper=imnoise(Image,’salt&pepper’,0.02);Usethedatad