| Re: Assigning NaN to arrays [message #39278] |
Sun, 09 May 2004 16:18 |
elv
Messages: 2 Registered: May 2004
|
Junior Member |
|
|
elv@irtf.ifa.hawaii.edu (Eric Volquardsen) wrote in message news:<49b2657.0405080139.3a293765@posting.google.com>...
> I was assigning NaN to the locations of bad pixels in an image. I
> then replace the bad pixels with the median of the surrounding good
> pixels. Instead of doing so, IDL assigned 2.14748e9. Everything I
> have seen in the IDL documentation seems to indicate that this would
> work.?.
>
> w = WHERE(mask EQ 1)
> size_img = SIZE(image, /dimensions)
> size_img = size_img[0]
> image[w] = !values.f_nan
> x = w MOD size_img
> y = w / size_img
> FOR i = 0, (n_elements(w)-1) DO image[w[i]] = MEDIAN(image[x-2:x+2,
> y-2:y+2])
Found the problem. For some reason, image "decided" it was an integer array.
Thanks,
Eric
|
|
|
|
| Re: Assigning NaN to arrays [message #39279 is a reply to message #39278] |
Sat, 08 May 2004 05:24  |
Chris Lee
Messages: 101 Registered: August 2003
|
Senior Member |
|
|
In article <49b2657.0405080139.3a293765@posting.google.com>, "Eric
Volquardsen" <elv@irtf.ifa.hawaii.edu> wrote:
> I was assigning NaN to the locations of bad pixels in an image. I then
> replace the bad pixels with the median of the surrounding good pixels.
> Instead of doing so, IDL assigned 2.14748e9. Everything I have seen in
> the IDL documentation seems to indicate that this would work.?.
> x = w MOD size_img
> y = w / size_img
> FOR i = 0, (n_elements(w)-1) DO image[w[i]] = MEDIAN(image[x-2:x+2,
> y-2:y+2])
Hi,
If the code is a direct copy-paste, you need some array indices on the
x and y arrays.
Otherwise, it works for me. You didn't say what your typical values are.
Is 2.14e9 not a possible value? Can you provide a sample 5 x 5 grid ?
..
a=findgen(5,5)
a[2,2]=!values.f_nan
print, median(a)
13.0000
..
Chris.
|
|
|
|