Image Processing Reference
In-Depth Information
Fig. 10.3 Image scaling using forward mapping. Notice the black pattern, which is a result of the
inherent problem related to forward mapping
10.2.1 Backward Mapping
The solution is to avoid forward mapping and instead use backward mapping . Back-
ward mapping maps from g(x ,y ) to f(x,y) . That is, it goes through the output
image , g(x ,y ) , one pixel at a time (using two for-loops) and for each position
(x ,y ) it uses the inverse transformation to calculate (x, y) . That is, it finds out
where in the input image a pixel must come from in order to be mapped to (x ,y ) .
The principle is illustrated in Fig. 10.2 (b). The inverse transformation is found by
matrix inversion of the transformation matrix as
1
x
y
1
x
y
1
a 1 a 2 a 3
b 1 b 2 b 3
001
=
·
(10.10)
For scaling, rotation and shearing the inverse matrices look like the following:
,
1 /S x 00
0 /S y
cos θ
sin θ
0
Scaling:
0
Rotation:
sin θ
cos θ
0
0
0
1
0
0
1
1
B x
0
1
Shearing:
B y
1
0
1
B x B y
0
0
1
B x B y
So, if we want to implement a program that as input takes an image f(x,y) and
as output gives a scaled image g(x',y'), then it could look something like this in
C-code:
Image_Width_Output
=
Image_Width_Input
Sx ;
Image_Height_Output
=
Image_Height_Input
Sy ;
Search WWH ::

Custom Search