[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rotten behavior with rot command



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.