smoothing filters gaussion and median filters comparing.ppt

ahmedshamsan2 94 views 26 slides Jun 13, 2024
Slide 1
Slide 1 of 26
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
Slide 26
26

About This Presentation

In the world of image processing, unwanted noise and details can make your pictures appear rough. Smoothing filters come to the rescue, offering a way to refine your images. These filters work by analyzing a pixel and its surrounding neighbors, then replacing the pixel's value with a new one tha...


Slide Content

Smoothing Filters
(low-pass)
1

Useful for reducing noise and removing
small details.
The elements of the mask must be
positive.
Mask elements sum to 1 assuming
normalized weights (i.e., divide each
weight by the sum of weights).
2

Smoothing filters –Example
SMOOTHED IMAGEINPUT IMAGE
3

Common Smoothing Filters
Averaging (linear)
Gaussian (linear)
Median filtering
(non-linear)
4

Smoothing Filters: Averaging
The mask weights are all equal to 1
5

Smoothing Filters: Averaging (cont’d)
Mask size determines
degree of smoothing (i.e.,
loss of detail).
3x3 5x5 7x7
15x15 25x25
original
6

Smoothing Filters: Averaging (cont’d)
15 X 15 AVERAGING AFTER IMAGE THRESHOLDING
Example: extract largest, brightest objects
ORGINAL
7

Smoothing filters: Gaussian
The mask weights are the sampled values of a 2D Gaussian:
8

Smoothing filters: Gaussian (cont’d)
Mask size depends on σ, e.g., it is usually chosen as follows:
9

Smoothing filters: Gaussian (cont’d)
•In this case, σcontrols the amount of smoothing
(since mask size depends on it)
σ= 3
σ= 1.4
10

Smoothing filters: Gaussian (cont’d)
EXAMPLE
11

Averaging vs Gaussian Smoothing
Averaging
Gaussian
12

BothaverageandGaussianfiltersareusedforsmoothinginimageprocessing,butthey
differintheirapproachandtheresultingeffects:
AverageFilter:
•Simpleandefficient:Itreplaceseachpixel'svaluewiththeaverageofitssurrounding
pixelsinadefinedneighborhood(likeasmallboxaroundthepixel).
•Equalweighting:Allneighboringpixelscontributeequallytothenewvalue,essentially
blurringtheimage.
•Sharperedgeloss:Sinceallpixelshavethesameweight,thefiltercanblursharpedges
anddetailssignificantly,especiallywithlargerneighborhoodsizes.
GaussianFilter:
•Weightedaverage:Italsousesaneighborhoodbutassignsweightstoeachpixelbased
itsdistancefromthecentralpixelbeingsmoothed.
•Bell-shapedcurve(Gaussianfunction):Theweightsfollowabell-shapedcurve,where
pixelsclosertothecenterhavehigherweights(contributemore)andthosefurtheraway
havelowerweights.
•Preservesedgesbetter:Bygivingmoreimportancetocloserpixels,thefiltercansmooth
outnoisewhilepreservingedgesandfinedetailstoagreaterextentcomparedtothe
averagefilter.
what is the difference between the average and
Gaussian filters in smoothing?
13

Feature Average Filter Gaussian Filter
Approach
Simple averaging of
neighbors
Weighted average
based on distance
Weighting
Equal weights for all
neighbors
Weights based on
Gaussian curve
Smoothing effect Strong blurring
Smoother image with
better edge
preservation
Detail preservation
Low (significant edge
loss)
Higher (better edge
preservation)
Computational
complexity
Lower Slightly higher
14

CODE EXAMPLE
15

Code results 16

17

Code results
18

ASIMPLEEXPLANATIONOFSMOOTHINGMEDIANFILTERING:
Imagineanoisyimage:Thinkofapicturewithspecksofrandomcolors(saltandpeppernoise)
orotherunwantedvariationsinpixelintensity.
TheMedianFilter:Ademocraticneighbor:Thisfilterfocusesonaspecificpixelandits
surroundingneighborhood(asmallgroupofpixelsaroundit).
Sortingtheneighborhood:Unliketheaveragefilter,whichcalculatestheaveragevalue,the
medianfiltersortsallthepixelvaluesintheneighborhoodfromlowesttohighest.
Themiddleman(orwoman):Thefilterthenpicksthevaluethatfallsexactlyinthemiddleof
thissortedlist.Thismiddlevalueiscalledthemedian.
Replacingtheoriginal:Finally,themedianvaluereplacestheoriginalvalueofthecentralpixel
intheimage.
Thebenefitofthemiddleground:Byusingthemedianinsteadoftheaverage,thefilteravoids
gettinginfluencedbyextremevalues(likethosecausedbynoise).Thishelpsinremovingnoise
noisewhilepreservingdetailsintheimage.
Thinkofitlikethis:Imagineagroupoffriendsdiscussingarestaurant'spricerange.The
medianfilterwouldchoosethepricethatmostpeopleagreeon(themiddlevalue),avoiding
gettingswayedbysomeonesuggestinganoverlyexpensiveorcheapoption.Thisapproach
providesamorerepresentativepictureofthepricerange.
Inessence,themedianfiltersmoothstheimagebyreplacingpixelvalueswiththemedianof
theirneighborhood,effectivelyremovingnoisewhilepreservingedgesanddetails.
19

Smoothing Filters: Median Filtering
(non-linear)
Very effective for removing “salt and pepper” noise (i.e.,
random occurrences of black and white pixels).
AVERAGING
MEDIAN
FILTERING
20

Smoothing Filters: Median Filtering (cont’d)
Idea: replace each pixel by the medianin a neighborhood around the
pixel.
The size of the neighborhood controls the amount of smoothing.
21

22

Code results for Median 23

GaussianFilter:
•Approach:AppliesaweightedaveragebasedonaGaussiandistribution(bell-shapedcurve).Pixels
closertothecenterhavehigherweights,contributingmoretothesmoothingeffect.
•Smoothingeffect:Providesasmoothandcontinuoustransitionbetweenpixels,effectivelyreducing
noisewhilepreservingedgestoacertainextent.
•Impactondetails:Mayslightlyblurfinedetailsduetotheaveragingprocess,especiallywithlarger
kernelsizes.
•Noisehandling:WorkswellforGaussiannoise(randomvariationsinpixelintensity)duetothe
averagingnature.
•Computationalcomplexity:Slightlyhighercomparedtomedianfilter.
MedianFilter:
•Approach:Replaceseachpixelwiththemedianvalueofitssurroundingneighborhood(sortedlistof
pixelintensities).
•Smoothingeffect:OffersasharpersmoothingeffectcomparedtoGaussianfilter,particularlyfor
edges.
•Impactondetails:PreservesdetailsandedgesbetterthanGaussianfilterduetoselectingthemiddle
value,notanaverage.
•Noisehandling:Particularlyeffectiveforimpulsivenoiselikesalt-and-peppernoise(randomblackor
whitepixels)asthemedianislessinfluencedbyextremevalues.
•Computationalcomplexity:LowercomparedtoGaussianfilter.
Both Gaussian and Median filters are used for smoothing images in image processing,
but they have distinct characteristics and work in different ways:
24

Feature Gaussian Filter Median Filter
Approach
Weighted average
(Gaussian)
Median of surrounding
pixels
Smoothing effect
Smooth and
continuous
Sharper, preserves
edges
Impact on details May blur fine detailsPreserves details better
Noise handling
Good for Gaussian
noise
Excellent for impulsive
noise
Computational
complexity
Slightly higher Lower
TABLE SUMMARIZING THE KEY DIFFERENCES 25

Choosingtherightfilter:
•Forsmoothingwithedgepreservation:Ifyouprioritizesmoothing
whilemaintainingsharpedgesandfinedetails,theGaussianfilterisa
goodchoice.
•Forremovingimpulsivenoise:Ifyourimagesuffersfromsalt-and-
peppernoiseorotherimpulsivenoisetypes,themedianfilterishighly
effective.
•Forbalancingsmoothinganddetailpreservation:Consider
experimentingwithbothfiltersandtheirparameters(kernelsizefor
Gaussian,kernelsizeformedian)tofindthebestbalanceforyour
specificimageprocessingtask.
Ultimately,thechoicedependsonthetypeofnoiseyou'redealing
withandthedesiredoutcomeforyourimagesmoothingprocess.
26