Image Processing Reference
In-Depth Information
And a pointer to the nine elements is: x1:= 0..8
And we get a vector of unsorted values: unsorted x1 :=
eye x+mod(x1,3)-1,x+floor
x1
3
-1
unsorted T =(146 146 146 152 155 152 152 155 150)
We need to sort these into ascending order: sorted:=sort(unsorted)
sorted T =(146 146 146 150 152 152 155 155)
And our median is the middle of the list: our_median:=sorted 4
our_median=152
So let's implement it as a general 3×
3 median operator:
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
So let's apply it: our_med:=med(eye)
0
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
10
11
12
0
0
0
0
0
0
0
0
0
0
135
146
152
152
146
146
117 117
135
0
139
146
152
152
146
117
117 117
139
0
146
146
152
152
146
117
117 117
139
0
146
146
150
150
136
117
117 135
139
our_med =
0
146
146
149
149
132
130
135 139
146
0
146
146
149
136 130
132
139 146
146
0
146
146
142
130
130
139
146 146
146
0
146
146
141
129
129
139
141 146
141
0
146
146
130
115
115
139
142 141
139
0
146
146
130
115
115
137
141 141
139
0
137
136
130
115
115
117
139 139
135
normalise (our_med)
0
137
130
117
115
115
117
135 135
135
(a)
(b)
Search WWH ::




Custom Search