Re: Rotten behavior with rot command [message #21187] |
Thu, 17 August 2000 00:00 |
landsman
Messages: 93 Registered: August 1991
|
Member |
|
|
In article <HJXm5.519$Df2.85677@news.shore.net>,
"Michael Baca" <mbaca@bos.fti-net.com> wrote:
> I have been experiencing a problem using the rot command. After reading
> through some code to find an error with a rotated array, I checked the
data
> created by the rot command. If I create a simple array, and then rotate
it,
> this is what I find:
>
> a=findgen(3,3)
> print, a
> 0.000000 1.00000 2.00000
> 3.00000 4.00000 5.00000
> 6.00000 7.00000 8.00000
>
> print, rot(a,180,/interp)
> 8.00000 7.00000 6.00000
> 5.00000 4.00000 3.00000
> 1.00000 0.000000 0.000000
>
> This is obviously not the answer I wanted, let alone the correct
> answer.
First, as a side note, what IDL version/platform are you using? On
sunos unix 5.3 I get a nicer answer for this particular case:
print,rot(a,180,/interp)
8.00000 7.00000 6.00000
5.00000 4.00000 3.00000
2.00000 1.00000 1.90719e-07
The better answer is that during a rotation, the corner pixels become
"missing data", i.e. except when the rotation is exactly a mulitple of
90 degrees, there are pixels in the output array for which there are no
corresponding values to interpolate in the input array. One way to
see which pixel values you should trust is to use the MISSING keyword,
i.e.
print,rot(a,180.0,missing = !VALUES.F_NAN)
which, for the particular roundoff error on my machine gives
7.00000 6.00000 NaN
5.00000 4.00000 3.00000
2.00000 1.00000 0.00000
My quick testing seems to show that whenver I get "nonsense" output
values, they are flagged as missing data when I supply the MISSING
keyword.
> Right now, the only way I can work around this problem is to find when
> a rotation is done
> in a 90 degree interval and then use the rotate command instead. But,
> this will not help when I need to rotate something, say, 170 degrees.
> Then the same error than causes the problem at 180 degrees still
> lingers.
I believe that if you flag the missing data, then the above method will
work. Use ROTATE when you know you are rotating exactly a multiple of
90 degrees; otherwise use ROT and flag the missing data.
--Wayne Landsman landsman@mpb.gsfc.nasa.gov
Sent via Deja.com http://www.deja.com/
Before you buy.
|
|
|
Re: Rotten behavior with rot command [message #21188 is a reply to message #21187] |
Thu, 17 August 2000 00:00  |
promashkin
Messages: 169 Registered: December 1999
|
Senior Member |
|
|
I did not find anything wierd when I tried it:
IDL> print, findgen(3,3)
0.00000 1.00000 2.00000
3.00000 4.00000 5.00000
6.00000 7.00000 8.00000
IDL> print, rot(findgen(3,3), 180, /interp)
8.00000 7.00000 6.00000
5.00000 4.00000 3.00000
2.00000 1.00000 1.90719e-07
IDL> print, rot(findgen(3,3), 90, /interp)
2.00000 5.00000 8.00000
1.00000 4.00000 7.00000
0.00000 3.00000 6.00000
I couldn't quite understand how ROT works with other settings but these
two appeared reasonable.
I'd check if there is some rounding happening somewhere in your code.
Cheers,
Pavel
|
|
|