Image Processing Reference
In-Depth Information
As discussed in Sect. 10.2 the forward mapping needs to be replaced by the
backward mapping. For the polar transformation, this can be found in the following
way:
y
x =
y
·
sin (x)
sin (x)
cos (x) =
cos (x) =
tan (x)
y
·
arctan y
x
x =
(11.5)
· cos (x) 2
sin (x) 2 =
x 2
y 2
y 2
cos (x) 2
y 2
sin (x) 2
y 2
y 2
+
=
·
+
·
=
+
x 2
y 2
y
=
+
(11.6)
To implement this a few things need to be done. First of all the angle, θ , needs to
be scaled so that its maximum value is 360. This is done by replacing x by
x
360
width
·
(11.7)
where width is the width of the input image. The height and width of the output
image will be two times the radius, i.e. two times the height of the input image.
Normally the size of the output image is therefore scaled by replacing y by y/ 2.
This will result in an output image where the height and width are equal to the
height of the input image.
The function arctan () behaves differently depending on the quadrant wherein it
is applied. This needs to be handled when implementing the function, but many
software libraries luckily have a built-in function that handles that, for example
ATAN2() in the C language.
The origin of the polar transform, ( 0 , 0 ) , is located in the center of the output
image which is (height/ 2 , height/ 2 ) . When going through the output image (using
two for loops) we therefore need to subtract height/ 2 from both x and y .Lastly,we
need to ensure that only valid values are processed. The invalid values can be seen
as the four white regions in the corners in Fig. 11.10 . We do this by only processing
pixels (x ,y ) those distance to the center of the image is equal to or below the
maximum radius height/ 2.
Combining all of the above we can rewrite Eqs. 11.5 and 11.6 as
arctan y
x
width
360 ·
=
x
(11.8)
y
=
2
·
r
(11.9)
where x = x x c , y = y y c , x c =
height/ 2 and y c =
height/ 2 are the center
x 2
y 2
of the input image, and r
=
+
is the radius. These equations only hold
when
r r max
(11.10)
Search WWH ::




Custom Search