FUNCTION REFLECTION,k,kc,ncols,nrows,row=row,column=column ;+ ;khat=REFLECTION(k,kc,ncols,nrows) is the reflection of image set k ;about the origin represented by kc. The number of columns and rows in the ;base image must be provided. Keywords /row and /column may be set to ;reflect the image around the row or column that contains kc instead of the point ;kc. ; ;If the reflected set is empty then khat=-1 is returned. ; ;HISTORY ;Default reflection written by HR Sept. 1999 for SIMG-782 ;Modified to reflect about row and column by JH Oct. 2000 for SIMG-782 ;- IF N_PARAMS() LT 4 THEN MESSAGE,'REFLECTION has too few arguments' ;Find the rectangular coordinats of the set points and the origin. x=k MOD ncols y=k/ncols xc=kc MOD ncols yc=kc/ncols ;Check for keyword specifying desired reflection and then carry that reflection out. if keyword_set(row) then begin ;Doing row reflection xr=x yr=2*yc-y endif else begin if keyword_set(column) then begin ;Doing column reflction xr=2*xc-x yr=y endif else begin ;Reflect about the origin. If x=xc + dx then xr=xc-dx=2*xc-x. ;Same for yr. xr=2*xc-x yr=2*yc-y endelse endelse ;Keep the points that fall within the base image frame. is=WHERE(xr GE 0 AND xr LT ncols AND yr GE 0 and yr LT nrows) if min(is) ge 0 then khat=yr[is]*ncols+xr[is] else khat=-1 RETURN,khat END