Image Processing Reference
In-Depth Information
So a 3×
3 template is:
0.111
0.111
0.111
!
!
averaging_template(3)=
0.111
0.111
0.111
0.111
0.111
0.111
and to apply it: smoothed:=tm_conv(eye,averaging_template(3))
Since there is a duality between convolution in the time domain and multiplication in
the frequency domain, we can implement template convolution by using the Fourier transform.
Template convolution is the inverse Fourier transform of the product of Fourier transform
of the image with the transform of the template. First we need a picture of the template, this
picture must be the same size as the image we want to convolve it with. For averaging, we
need a 3×
3 square in the centre of an image of the same size as the eye image:
for x 0..cods(eye)-1
for y 0..rows(eye)-1
square:=
rows(eye)
2
rows(eye)
2
1
9 if y
y,x
pic
-1
y
+1
cols(eye)
2
cols(eye)
2
x
-1
x
+1
pic y,x
0 otherwise
pic
Then, template convolution is given by:
conv(pic,temp):= pic_spectrum
Fourier(pic)
Take transform of image
temp_spectrum
Fourier(temp)
Transform template
convolved_spectrum
(pic_spectrum temp_spectrum)
Form product
result inv_Fourier
(rearrange(convolved_spectrum)) Inverse transform
result
Supply result
Let's see what happens: Fsmoothed:=conv(eye,square)
To check the result, we need to scale its magnitude:
sc_smooth:= cols(eye)· |Fsmoothed|
Now, let's see the difference
Search WWH ::




Custom Search