You are on page 1of 11

Machine Vision

140.429 Digital Image Processing

Adaptive Median Filtering


KEY WOEDS

Digital image processing, Pixel, Neighborhood, Median filter, Mean filter (average filter), Linear & non-linear filter, Image smoothing, Image enhancement, Imp lse noise (salt & pepper noise) The basic operation of digital image processing !o nderstand "hat adaptive median filtering is all abo t, one first needs to nderstand "hat a median filter is and "hat it does# In man$ different %inds of digital image processing, the basic operation is as follo"s& at each pixel in a digital image "e place a neighborhood aro nd that point, anal$'e the val es of all the pixels in the neighborhood according to some algorithm, and then replace the original pixel(s val e "ith one based on the anal$sis performed on the pixels in the neighborhood # !he neighborhood then moves s ccessivel$ over ever$ pixel in the image, repeating the process#

What a median filter is and what it does

Median filtering follo"s this basic prescription# !he median filter is normall$ sed to red ce noise in an image, some"hat li%e the mean filter# )o"ever, it often does a better *ob than the mean filter of preserving sef l detail in the image# !his class of filter belongs to the class of edge preserving smoothing filters "hich are non-linear filters# !his means that for t"o images A(x) and B(x)&

!hese filters smooths the data "hile %eeping the small and sharp details# !he median is * st the middle val e of all the val es of the pixels in the neighborhood# Note that this is not the same as the average (or mean)+ instead, the median has half the val es in the neighborhood larger and half smaller# !he median is a stronger ,central indicator, than the average# In partic lar, the median is hardl$ affected b$ a small n mber of discrepant val es among the pixels in the neighborhood# -onse. entl$, median filtering is ver$ effective at removing vario s %inds of noise# /ig re 0 ill strates an example of median filtering#

Machine Vision

140.429 Digital Image Processing

Fig!re "

Li%e the mean filter, the median filter considers each pixel in the image in t rn and loo%s at its nearb$ neighbors to decide "hether or not it is representative of its s rro ndings# Instead of simpl$ replacing the pixel val e "ith the mean of neighboring pixel val es, it replaces it "ith the median of those val es# !he median is calc lated b$ first sorting all the pixel val es from the s rro nding neighborhood into n merical order and then replacing the pixel being considered "ith the middle pixel val e# (If the neighborhood nder consideration contains an even n mber of pixels, the average of the t"o middle pixel val es is sed#) /ig re 1 ill strates an example calc lation#

Fig!re # -alc lating the median val e of a pixel neighborhood# 2s can be


2

Machine Vision

140.429 Digital Image Processing

seen, the central pixel val e of 034 is rather nrepresentative of the s rro nding pixels and is replaced "ith the median val e& 015# 2 676 s. are neighborhood is sed here --- larger neighborhoods "ill prod ce more severe smoothing# What is noise Noise is an$ ndesirable signal# Noise is ever$"here and th s "e have to learn to live "ith it# Noise gets introd ced into the data via an$ electrical s$stem sed for storage, transmission, and8or processing# In addition, nat re "ill al"a$s pla$s a ,nois$, tric% or t"o "ith the data nder observation# 9hen enco ntering an image corr pted "ith noise $o "ill "ant to improve its appearance for a specific application# !he techni. es applied are applicationoriented# 2lso, the different proced res are related to the t$pes of noise introd ced to the image# :ome examples of noise are& ;a ssian or 9hite, <a$leigh, :hot or Imp lse, periodic, sin soidal or coherent, ncorrelated, and gran lar#

$oise Models Noise can be characteri'ed b$ its& Probabilit$ densit$ f nction (pdf)& ;a ssian, niform, Poisson, etc# :patial properties& correlation /re. enc$ properties& "hite noise vs pin% noise

Machine Vision

140.429 Digital Image Processing

Fig!re % =riginal Image

Fig!re & Images and histograms res lting from adding ;a ssian, <a$leigh and ;amma noise to the original image#

Machine Vision

140.429 Digital Image Processing

Fig!re & (contin ed) Images and histograms res lting from adding >xponential, ?niform and :alt & Pepper noise to the original image#

'omparison between the median filter and the average filter :ometimes "e are conf sed b$ median filter and average filter, th s let@s do some comparison bet"een them# !he median filter is a non-linear tool, "hile the average filter is a linear one# In smooth, niform areas of the image, the median and the average "ill differ b$ ver$ little# !he median filter removes noise, "hile the average filter * st spreads it aro nd evenl$# !he performance of median filter is partic larl$ better for removing imp lse noise than average filter# 2s /ig re 3 sho"n belo" are the original image and the same image after it has been corr pted b$ imp lse noise at 04A# !his means that 04A of its pixels "ere replaced b$ f ll "hite pixels# 2lso sho"n are the median filtering res lts sing 6x6 and 3x3 "indo"s+ three (6) iterations of 6x6 median filter applied to the nois$ image+ and finall$ for comparison, the res lt "hen appl$ing a 3x3 mean filter to the nois$ image#

Machine Vision

140.429 Digital Image Processing

a)=riginal image+

b)2dded Imp lse Nois$ at 04A

a)6x6 Median /iltered+

b)3x3 Median /iltered

-omparison of the non-linear Median filter and the linear Mean filter#

Machine Vision

140.429 Digital Image Processing

a)6x6 Median /iltered applied 6 times+ b)3x3 2verage /ilter Fig!re ( The disadvantage of the median filter 2ltho gh median filter is a sef l non-linear image smoothing and enhancement techni. e# It also has some disadvantages# !he median filter removes both the noise and the fine detail since it can(t tell the difference bet"een the t"o# 2n$thing relativel$ small in si'e compared to the si'e of the neighborhood "ill have minimal affect on the val e of the median, and "ill be filtered o t# In other "ords, the median filter can(t disting ish fine detail from noise#

Adaptive Median Filtering !herefore the adaptive median filtering has been applied "idel$ as an advanced method compared "ith standard median filtering# !he 2daptive Median /ilter performs spatial processing to determine "hich pixels in an image have been affected b$ imp lse noise# !he 2daptive Median /ilter classifies pixels as noise b$ comparing each pixel in the image to its s rro nding neighbor pixels# !he si'e of the neighborhood is ad* stable, as "ell as the threshold for the comparison# 2 pixel that is different from a ma*orit$ of its neighbors, as "ell as being not str ct rall$ aligned "ith those pixels to "hich it is similar, is labeled as imp lse noise# !hese noise pixels are then replaced b$ the median pixel val e of the pixels in the neighborhood that have passed the noise labeling test# )!rpose 0)# <emove imp lse noise
7

Machine Vision

140.429 Digital Image Processing

1)# :moothing of other noise 6)# <ed ce distortion, li%e excessive thinning or thic%ening of ob*ect bo ndaries

*ow it wor+s B 2daptive median filter changes si'e of :x$ (the si'e of the neighborhood) d ring operation# B Notation Cmin D minim m gra$ level val e in :x$ Cmax D maxim m gra$ level val e in :x$ Cmed D median of gra$ levels in :x$ Cx$ D gra$ level at coordinates (x, $) :max D maxim m allo"ed si'e of :x$ B 2lgorithm Level 2& 20 D Cmed - Cmin 21 D Cmed - Cmax if 20 E 4 2ND 21 F 4, go to level G else increase the "indo" si'e if "indo" si'e F :max, repeat level 2 else o tp t Cx$ Level G& G0 D Cx$ - Cmin G1 D Cx$ - Cmax if G0 E 4 2ND G1 F 4, o tp t Cx$ else o tp t Cmed

B >xplanation Level 2& I/ Cmin F Cmed F Cmax, then H Cmed is not an imp lse (0) go to level G to test if Cx$ is an imp lse ### >L:> H Cmed is an imp lse (0) the si'e of the "indo" is increased and (1) level 2 is repeated ntil ### (a) Cmed is not an imp lse and go to level G or (b) :max reached& o tp t is Cx$ Level G& I/ Cmin F Cx$ F Cmax, then H Cx$ is not an imp lse (0) o tp t is Cx$ (distortion red ced) >L:> H either Cx$ D Cmin or Cx$ D Cmax
8

Machine Vision

140.429 Digital Image Processing

(1) o tp t is Cmed (standard median filter) H Cmed is not an imp lse (from level 2)

Advantages !he standard median filter does not perform "ell "hen imp lse noise is a. ;reater than 4#1, "hile the adaptive median filter can better handle these noises# b. !he adaptive median filter preserves detail and smooth non-imp lsive noise, "hile the standard median filter does not# :ee example form a) to d) in fig re I#

Machine Vision

140.429 Digital Image Processing

a) Image corr pted b$ imp lse noise "ith a probabilit$ of 4#0+

b) <es lt of arithmetic mean filtering+

c) <es lt of adaptive median filtering+ d) <es lt of standard median filtering Fig!re ,

10

Machine Vision

140.429 Digital Image Processing

11

You might also like