; NAME: ; CURVEFRAME ; ; PURPOSE: ; Returns a 2D array that is the input frame curved using a sine ; function a specified amount ; ; CALLING SEQUENCE: ; Result = CURVEFRAME(inframe, xamp, xosc, yamp, yosc, xmax=xmax, ; ymax=ymax) ; ; INPUTS: ; Inframe = The frame to be curved ; XAmp = The amplitude of the sine curvature in x direction ; XOsc = The number of cycles in one frame in x direction ; YAmp = The amplitude of the sine curvature in y direction ; YOsc = The number of cycles in one frame in y direction ; ; OUTPUT: ; Returns the input frame curved using a sine function in the x ; and y direction ; ; REQUIRES: ; Inorder for the frame not to loop information there should be a ; buffer of the amplitude in that direction around the frame ; ; PROCEDURE: ; Calculate the sine function, and shift each pixel by that ; amount, first shifting in x, then shifting the resulting frame ; in y. ; ; MODIFICATION HISTORY: ; created Jun 30 2003 by John Dermody function curveframe, inframe, xamp, xosc, yamp, yosc, xpos=xpos, xin=xin ; get sizes tx = (size(inframe))[1] ty = (size(inframe))[2] ; create sine function for each dimension yval = findgen(ty) xval = findgen(tx) if keyword_defined(xin) then begin xpos = xin endif else begin xpos = sin(yval / ty * 2 * !pi * xosc) * xamp endelse ypos = sin(xval / tx * 2 * !pi * yosc) * yamp ; make a map of each old position to its new position xmap = (floor(xpos) ## (1 + fltarr(tx))) + findgen(tx, ty) ymap = ((1 + fltarr(ty)) ## floor(ypos)) * tx + findgen(tx, ty) ; the error is the differance between the actual result postion and the ; calulated position xlerror = (floor(xpos+1) - xpos) ## (1 + fltarr(tx)) xherror = (xpos - floor(xpos)) ## (1 + fltarr(tx)) ylerror = (1 + fltarr(ty)) ## (floor(ypos+1) - ypos) yherror = (1 + fltarr(ty)) ## (ypos - floor(ypos)) ; curve the frame, with new values equal to the old values times the ; error at that position. xcurveframe = fltarr(tx, ty) ycurveframe = fltarr(tx, ty) xcurveframe[xmap ] = inframe * (xlerror) xcurveframe[xmap+1 ] = xcurveframe[xmap+1 ] + inframe * (xherror) ycurveframe[ymap ] = xcurveframe * (ylerror) ycurveframe[ymap+tx] = ycurveframe[ymap+tx] + xcurveframe * (yherror) curveframe = ycurveframe return, curveframe end