comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Assigning NaN to arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Assigning NaN to arrays [message #39278] Sun, 09 May 2004 16:18
elv is currently offline  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 Go to previous message
Chris Lee is currently offline  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.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: WIDGET_COMBOBOX
Next Topic: What is this error message about?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Mar 28 05:14:06 PDT 2026

Total time taken to generate the page: 2.16063 seconds