Re: Questions about the Log Polar Transform.
- From: davem@xxxxxxxxx (Dave Martindale)
- Date: Thu, 14 Jul 2005 16:03:10 +0000 (UTC)
"Robin Tucker" <idontwanttobespammedanymore@xxxxxxxxxxxxxxx> writes:
>Forgive me but I'm a bit new to all this; as I understand it, the polar
>transform maps radial lines in Cartesian space to horizontal lines in polar
>coordinate space:
>Like this:
>[1] r = sqrt ( ( x - xc ) ^2 + ( y - yc ) ^ 2 )
>[2] a = tan-1 ( ( y - yc ) / ( x - xc ) )
>So I can calculate r and a for each point in a source image using [1] and
>[2].
That formula will only give you angles between -90 and +90 degrees. To
get proper polar coordinates, you'll have to use atan2(), or look at
the sign of (x-xc) and make a correction to get angles in the left half
of the plane.
That's the first half of the mapping. This gives you the polar
coordinates of the pixel in the source image. Then you have to map
that to a new position (x', y') in the destination image using
something like
x' = k1 * r + k2
y' = k3 * a + k4
where k1-k4 are constants used to set the size of the output image and
make the X and Y addresses all positive.
If you want a log-polar output image, not just a polar one, you'll also
need to change "r" to "log(r)" in the above.
>Now correct me if I'm wrong, but I cannot apply a transform to the source
>image purely by performing a linear interpolation of a pixel from the source
>image at the destination image between r1 and r2 and a1 and a2 (where r1,
>r2, a1, a2 are the minimum and maximum r and a in the source image).
No, you need to apply the transformation point by point, since it is not
a linear mapping.
>How do I map the source pixel (x, y) through polar coordinates (r, a) onto a
>destination image?
>Should I use something like x = [r cos a], y = [r sin a]?
The easiest thing to do in this case is to operate in output image
space. For every pixel location (x', y') in the output image, calculate
the input pixel location (x, y) by inverting the expressions above.
This will give you a position that isn't exactly aligned with any input
pixel.
For a quick and dirty test, just round the position to the nearest
integer (x, y) and use that pixel - this is called nearest neighbour
resampling. If you want a good-quality output image, you will need to
interpolate between several input pixels to determine the output pixel
value. Bilinear interpolation between 4 input pixels is cheapest,
bicubic interpolation using 16 input pixels is better, and the
resampling literature can provide even better (and more expensive)
interpolation.
Dave
.
- Follow-Ups:
- Re: Questions about the Log Polar Transform.
- From: Robin Tucker
- Re: Questions about the Log Polar Transform.
- References:
- Questions about the Log Polar Transform.
- From: Robin Tucker
- Questions about the Log Polar Transform.
- Prev by Date: Re: Questions about the Log Polar Transform.
- Next by Date: Re: Questions about the Log Polar Transform.
- Previous by thread: Re: Questions about the Log Polar Transform.
- Next by thread: Re: Questions about the Log Polar Transform.
- Index(es):
Relevant Pages
|