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

Home » Public Forums » archive » interpolate over bad pixels
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
interpolate over bad pixels [message #44561] Mon, 27 June 2005 15:22 Go to next message
Em is currently offline  Em
Messages: 2
Registered: June 2005
Junior Member
I was hoping you could help me out here. I have a set of images where a
few pixels are bad, or set to "NaN". Can you tell me how I can
interpolate over these bad pixels, using preferrably a spline or cubic
interpolation? The region with bad pixels is usually around 3-8 pixels
in diameter on a 1024x1024 image. Is there a routine that takes the
image and a list of the indices of bad pixels, and outputs an
interpolated image?

I have looked at the convol routine, and tri_surf. If these do what I
need them to do, I have not figured out how to use them...

Thanks,
Em
Re: interpolate over bad pixels [message #44642 is a reply to message #44561] Wed, 29 June 2005 03:06 Go to previous message
Jess is currently offline  Jess
Messages: 11
Registered: June 2005
Junior Member
Hi again Em,

This is what I'm now doing for the 1D arrays which works really well.
I'm sure its not the fastest, but it works fine. Below I've given the
syntax for a 2D example (sorry if its not quite right, as I haven't
tested this 2D one).

Create 3 arrays, one that contains just the indices of the good pixels,
second that contains just the values of the good pixels, and third that
contains the indices of all the pixels, eg.

; where not eq NAN
wh_good = WHERE(FINITE(orig_image))
; image with just good pixels
image_good = orig_image(wh_good)

; size of image
dimens = size(orig_image,/dimensions)
xnum = dimens[0]
ynum = dimens[1]
; indices of all pixels
wh_all = indgen(xnum,ynum)

; Then interpolate, to get corrected image
; eg. linear interpolation
image_corr = interpol(image_good,wh_good,wh_all)
; or for cubic spline
image_corr = interpol(image_good,wh_good,wh_all,/spline)

Have a look at the help on where, finite and interpol.

Cheers,
Jess
Re: interpolate over bad pixels [message #44646 is a reply to message #44561] Tue, 28 June 2005 19:56 Go to previous message
Jess is currently offline  Jess
Messages: 11
Registered: June 2005
Junior Member
Hi Em,

Sorry I can't help but this seems similar to what I want to do except
yours is 2D whereas I want to expand a vector with congrid, but have it
only use certain pixels (in my case non-zero pixels) and have it
stretch and interpolate correctly. i ended up writing an iterative
script which was sufficient in the vector case, but would much prefer a
smarter way and being able to do it over 2D images also.

Look forward to the solutions you get,
Jess
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Symbol's value as variable is void: idlwave-sys-dir
Next Topic: dialog_pickfile: changing default view in windows

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

Current Time: Fri Oct 10 16:16:01 PDT 2025

Total time taken to generate the page: 0.64099 seconds