Image Processing Reference
In-Depth Information
sorted := sort (unsorted)
Code 3.11
Using the Mathcad sort function
our median := sorted 4
Code 3.12
Determining the median
These functions can then be grouped to give the full median operator as in Code 3.13 .
med(pic) := newpic zero(pic)
for x 1..cols(pic)-2
for y 1..rows(pic)-2
for x1 0..8
unsorted
pic
x1
x1
3
y+mod(x1,3)-1,x+floor
-1
sorted sort(unsorted)
newpic y,x
sorted 4
newpic
Code 3.13
Determining the median
The median can of course be taken from larger template sizes. It is available as the
median operator in Mathcad, but only for square matrices. The development here has
aimed not only to demonstrate how the median operator works, but also to provide a basis
for further development. The rank ordering process is computationally demanding ( slow )
and this has motivated use of template shapes other than a square. A selection of alternative
shapes is shown in Figure 3.20 . Common alternative shapes include a cross or a line
(horizontal or vertical), centred on the point of interest, which can afford much faster
operation since they cover fewer pixels. The basis of the arrangement presented here could
be used for these alternative shapes, if required.
(a) Cross
(b) Horizontal line
(c) Vertical line
Figure 3.20
Alternative template shapes for median operator
The median has a well-known ability to remove salt and pepper noise . This form of
noise, arising from, say, decoding errors in picture transmission systems, can cause isolated
Search WWH ::




Custom Search