Median filter the hard way [message #36766] |
Thu, 16 October 2003 17:15 |
Peter Payzant
Messages: 3 Registered: July 2003
|
Junior Member |
|
|
Hello, all-
This is my first posting to the group. I'm a relative novice at IDL (though
not at programming), and I'm hoping that someone may be able to help me with
a problem that a colleague is having.
He is applying a median filter to a 2-dimensional image. In general, he
wants to build a new image, where each pixel is the median value of the 3 x
3 array centred on the corresponding pixel in the original image.
Unfortunately, the image is corrupted by missing data, which are represented
by NaN. If there less than 7 good values in the 3 x 3 array, he discards
the original pixel.
His code is something like this:
for each row in the image
for each pixel in the row
count the finite neighbours of the pixel
if the count is 7 or greater then
new_pixel = median value
else
new_pixel = NaN
next pixel
next row
Obviously, the nested loops are the source of the problem. Is there any
other way to accomplish this, in a more IDL-esque way?
Thanks
Peter Payzant
Waverley, NS Canada
pce "at" accesswave "dot" ca
|
|
|