PRO image_bp_interp, imdata, bpmdata, status ; Description: This module interpolates over the bad pixels in the image array "imdata", where ; the bad pixels are flagged in the bad pixel mask "bpmdata". For each bad pixel ; in "imdata", the module finds the smallest square centred on the bad pixel that ; contains at least one good pixel, and then, after growing the square by one ; pixel in each direction, calculates the mean of all good image pixel values ; within the square. This mean value is taken as the replacement pixel value for ; the current bad pixel. When all bad pixels have been interpolated over, the ; module sets the value of "status" to "1". ; ; Input Parameters: ; ; imdata - FLOAT/DOUBLE ARRAY - An image array for which bad pixels are to be interpolated. ; bpmdata - BYTE/INTEGER/LONG ARRAY - A bad pixel mask array of the same size as "imdata" ; which flags bad pixels with a value of "0" and good ; pixels with a value of "1". If this array does not ; have the same dimensions as "imdata", then the module ; does no interpolation on "imdata". ; ; Output Parameters: ; ; imdata - FLOAT/DOUBLE ARRAY - The image array after interpolating over bad pixels. ; status - INTEGER - If the bad pixels in "imdata" were interpolated over successfully, then ; "status" is set to "1". Otherwise, if "imdata" is not an image, or ; "bpmdata" does not have the same dimensions as "imdata", then "status" ; is set to "0". ; ; Author: Dan Bramich (dan.bramich@hotmail.co.uk) ; ; History: ; ; 14/08/2008 - Module created (dmb) ;Check that "imdata" is an image of the correct number type ;Check that "bpmdata" is an image of the correct number type and dimensions ;Determine the total number of good pixels in the image ;If there are no bad pixels in the image, then return with the parameter "status" equal to "1", ;and without doing anything ;If there are no good pixels in the image, then return with the parameter "status" equal to "0", ;and without doing anything ;For each pixel in the input image ;If the current pixel is a bad pixel ;Find the smallest square centred on the bad pixel that contains at least one good pixel ;Define a square ;Determine the number of good pixels in the square ;Increment the square size ;Grow the square by one pixel in each direction on each side ;Interpolate the bad pixel value as the mean of the good pixel values within the chosen square ;Set the "status" parameter to "1"