Graphics Reference
In-Depth Information
⎧
⎨
)
3
+
27
(
1
)
2
+
9
(
1
−
21
(
1
−|
x
|
−|
x
|
−|
x
|
)+
1,
−
1
≤
x
≤
1
f
M
(
x
)=
1
18
)
3
)
2
,
7
(
2
−|
x
|
−
6
(
2
−|
x
|
1
≤|
x
|≤
2
⎩
0,
otherwise
(19.12)
Table 19.1 shows several filters and their Fourier transforms.
The function sinc is band-limited at
v
0
=
2
. The cubic B-spline filter
b
3
is
not,
and it passes frequencies much larger than
1
2
, albeit attenuated. As we showed
in Chapter 18, the consequence of this is aliasing. A signal at frequency 0.5
+
a
appears as an alias at frequency 0.5
a
. In particular, integer-spaced samples of
a signal of frequency near 1 look like samples of a signal of frequency near 0.
Indeed, any near-integer frequency aliases to a low frequency.
If we use a filter like
b
3
to reconstruct a continuum signal from image data, the
resultant signal will contain aliases, because the support of
b
3
is not contained in
H
=(
−
2
,
2
]
. Fortunately, outside
H
the Fourier transform falls off fairly rapidly;
nonetheless, there is some aliasing.
We can address this with a compromise: We can stretch
b
3
along the
x
-axis so
that the Fourier transform compresses along the
1
−
-axis, pushing more of the sup-
port inside
H
and reducing aliasing. This has the unfortunate consequence that fre-
quencies that we'd like to preserve, near
v
1
2
, end up attenuated. The compromise
involved is one of trading off blurriness (i.e., a lack of frequencies near
±
=
2
)
|
v
|
against low-frequency aliasing (i.e., frequencies near
=
1). For frequencies
in between these extremes, aliasing still occurs. But if a frequency just above
2
aliases to one just below
2
, it's often removed during image shrinking anyhow,
and in practice turns out to not be as noticeable as an alias at a frequency near 0.
|
v
|
In general, convolving an image with a discrete filter of small support can be an
interesting proposition. We already saw how convolving with a 3
3 array of
ones can blur an image (although to keep the mean intensity constant, you need to
divide by nine).
In general, we can store a discrete filter in a
k
×
×
k
array
a
, and the image in an
n
×
n
array
b
; the result of the convolution will then be an
(
n
+
k
)
×
(
n
+
k
)
array
c
; the code is given in Listing 19.4.
Listing 19.4: Convolving using the “extend by zeroes” rule.
1
2
3
4
5
6
7
8
void discreteConvolve (float a[k][k], float b[n][n], float c[n+k-1][n+k-1])
initialize c to all zeroes
for each pixel
(
i
,
j
)
of
a
for each pixel
(
p
,
q
)
of
b
row =
i
p
;
col =
j
+
q
;
if (row <
n
+
k
−
1
) && (col <
n
+
k
−
1
))
c[row][col] += a[
i
][
j
]
*
b[
p
][
q
];
+