2-D linear interpolation with bad pixel values
Frank Valdes wrote on Dec 17, 1998
Q: I am interested in performing a 2-D linear interpolation on an image. The complication is that I want the interpolation to ignore pixels with values, say, of zero. I've looked at programs like magnify, but have not found the option to ignore zero-valued pixels. Do you have any suggestions? A: What you would like is desirable but the current versions of the interpolation tasks do not provide the ability to ignore flagged pixels. I suggest you do the following. 1. Make a mask (an image with .pl extension) of the pixels you want to ignore. If you already have them set to zero then use the command cl> imexpr "a == 0 ? 1 : 0" mask.pl image This makes mask.pl based on image where any value of 0 has a mask value of 1 (which means a flagged or bad pixel) and zero otherwise. If you have real data you may need to use a looser test than a==0 such as abs(a)<0.0001. 2. Use FIXPIX to replace the flagged pixels by interpolation from neighboring pixels. You need to do this to avoid having the interpolator do funny things around the zero valued pixels. 3. Do the interpolation. If the interpolation changes the coordinates, such as scale change or shifts, and you want to do step 4 below to replace the original flagged pixels by zero again, do the following. Set the mask values to a larger value (in step 1 use a value of 1000 instead of 1 or just use IMARITH to multiply). Interpolate the mask in exactly the same way as the image. [For large images there can be a bug such that the output of the interpolation to a .pl output image name is wrong. In this case interpolate to a regular image as output and then convert back to a mask (or simply leave it alone for step 4).] 4. You can then restore the flagged pixels to zero (if you want otherwise the information is in the mask) with cl> imexpr "b == 1 ? 0 : a" newimage image mask where "image" is the interpolated image and mask is the mask image giving the location of the flagged pixels. This mask would either be the original mask if the interpolation did not change the coordinates or the interpolated mask if it did. This is done with Mosaic data and works well (but the pixels are always left at the interpolated values rather than the original values or a flag value). The interpolated masks are used to stack dithered images so that the missing values are actually replaced with real data rather than interpolation from surrounding data.
Last post on Dec 17, 1998