Graphics Reference
In-Depth Information
To scale up a source image in two dimensions, we simply scale each row first,
then scale each column (see Figure 19.3).
Scale up
rows
Inline Exercise 19.2: Convince yourself that scaling rows-then-columns
results in the same image as scaling columns-then-rows.
Scale up
columns
19.3 Scaling Down an Image
We now turn to the more complicated problem of scaling down an image I , that is,
making it smaller. We'll assume that the source image has N pixels and the target
image has only K
Figure 19.3: Scaling up rows
and then columns to enlarge
an image (Original image from
http://en.wikipedia.org/wiki/File:
Mona_Lisa,_by_Leonardo_da_
Vinci,_from_C2RMF_retouched
. jpg.)
N pixels.
Once again we can reconstruct from integer samples by convolving with sinc
to get the original signal S . But in the next step, when we build
T ( x )= S K
N
<
x ,
(19.6)
y
= F
( I )(
v
)
1
the resultant function is no longer band-limited at
2 ; instead, it's band-limited at
N
2 K
1
2 . Before we could safely sample T , we would have to band-limit it to
frequency 2 by convolving with sinc.
>
y
=
b (
v
)
Let's look at the process in the frequency domain, as shown schematically in
Figure 19.4. In reconstructing S , we convolved with sinc, that is, we multiplied
by a width-one box in the frequency domain. When we squashed S to produce T ,
we stretched the Fourier transform of S correspondingly, and then needed to once
again multiply by a unit-width box.
1
1
-
2
2
Reconstruct
F ( S )
=
F ( I )
?
b
N before stretching, as
shown in Figure 19.5? Then when we stretch the result by N
What if we instead multiplied by a box of width K
/
F ( T )
/
Stretch
K , we'll already be
v 0 = 2 . So, in the frequency domain, the sequence of operations
band-limited at
is as follows.
F ( T )
?
b
Filter
1. Multiply by
v
b (
) to reconstruct.
v
K
2. Multiply by
v
b (( N
/
K )
) to band-limit to
2 N .
v
1
3. Stretch by a factor of N
/
K ; the result is band-limited at
2 .
Figure
19.4:
Band-limiting
S
after scaling.
4. Convolve with
ψ
as a result of sampling at integer points.
Notice that the first two steps can be combined: Multiplying by a wide box and
then a narrow box gives the same result as multiplying by just the narrow box! This
means that instead of reconstructing and then band-limiting, we can reconstruct
and band-limit in a single step, by using a wider sinc-like function in the recon-
struction process. Instead of x
y = F ( I )( v )
1
N
2
v
y
=
b
K
1
1
-
Reconstruct
and band-limit
N sinc ( N x ) .After
that, all the remaining steps are the same. The program is shown in Listing 19.3.
K
2
sinc ( x ) , we need to use x
2
N
1
1
22
F ( S )
?
v A
b
v
K
Listing 19.3: Scaling down a one-dimensional source image.
Stretch
1
2
3
4
5
6
void scaledown(source, target, N, K)
{
F ( T )
?
b
assert(K <= N);
for (j = 0; j < K; j++) {
target[j] = SL((N/K) * (j + 0.5) - 0.5, source, N, K);
Figure
19.5:
Band-limiting
S
}
before scaling.
 
 
 
Search WWH ::




Custom Search