PRO dical_interp, img, loc, VERT=vert, MAXSIZE=maxsize, FLAGS=flags ;;----------------------------------------------------------------------------- ;; PURPOSE: ;; Performs thin plate spline interpolation across segments of the given ;; image. At the edges, pixels are repeated, instead of extrapolated. ;; ;; CALLING SEQUENCE: ;; DICal_interp, img, loc, /VERT ;; ;; REQUIRED INPUTS: ;; img - The image to perform the interpolation on ;; loc - result of a WHERE call specifiying where to interpolate over ;; ;; OUTPUTS: ;; The image with the areas interpolated over ;; ;; OPTIONAL INPUT KEYWORDS: ;; VERT - only interpolate in the vertical direction. Used for IR images. ;; MAXSIZE - the maximum size of a region to interpolate over in 2D interpolation ;; FLAGS - flags identifying where the invalid pixels are ;; ;; EXAMPLE: ;; IDL> dical_interp, in, loc ;; ;; PROCEDURES USED (i.e. called directly!): ;; find_2Dblobs ;; ;; MODIFICATION HISTORY: ;; 2004-08-19 M. Desnoyer Created ;; ;;----------------------------------------------------------------------------- @dical_flags img = double(img) dim = size(img, /dimensions) IF NOT keyword_set(maxSize) THEN maxSize = 9999 IF size(loc, /n_dimension) EQ 0 THEN RETURN ;; Nothing to interpolate over ;; Determine where the invalid data resides badData = where(flags NE 0) IF keyword_set(VERT) THEN BEGIN ;; 1D interpolation along the columns img = dical_irinterp(img,loc,badData) ;; Modify the flags flags[loc] = flags[loc] OR FLAG_INTERP ENDIF ELSE BEGIN ;; 2D Interpolation ;; Group the gaps by size gaps = find_2DBlobs(loc, dim[0], SIZE=gapSize) ;; Remove the gaps that are too big justRight = where((gapSize[0,*]