clip_imshift_trs

Transform one image (the input image, arg1) into the coordinate system of another image (arg2) using parameters in a TRS file. I usually use an ds9-based interactive code like ds9_xymatch to derive the TRS file.




clip_imshift_trs.sh --help Usage: clip_imshift_trs.sh img1.fits img2.fits TRANS.fits arg1 - input FITS image (to be shifted) arg2 - image defining system to be transformed to arg3 - name of output image clip_imshift_trs.sh: Transform an image (img1) to the coordinate system of another image (img2). You must have a TRS paramter file with the name of the form: img2_XY2XY_img1.TRS
So, to perform the above transformation of img1 into the img2 system we need to have the TRS parameters to take an (X,Y) in the img2 syste and predict what (X,Y) this lands in for the img1 system. In practice, we'll run through every pixels in img2.fits. We'll predict that pixels location in the img1.fits system. We'll take the img1 pixel value and place it inthe output image (which has the same coordinate system as img2.fits).

Describing this process is confusing. Since I have to handle so many pixels in a procedure like this, I don't use the actual trs_ routines. Instead I use an OTW code that does all of the transformation steps. Here are the steps to code performs:



TRS file contains:    xofirst yofirst  reflect  fscal  theta   xolast  yolast 

I loop through the X,Y position of every pixel in img2, and:
  xx,yy = X,Y in the img2 system 

 Step 1:  First translation 
  x1 = xx - xofirst
  y1 = yy - yofirst

 Step 2: Reflection     (can be  "X", "Y", or"N" for No reflection)
   y2 = -y1 for reflection about X axis   
   x2 = -x1 for reflection about Y axis   

 Step 3: Scale the values 
   x3 = x2*fscal
   y3 = y2*fscal

 Step 4: Rotate 
   x4 = x3*crot + y3*srot
   y4 = y3*crot - x3*srot

 Step 5:  Second (final) translation 
   x5 = x4 - xolast
   y5 = y4 - yolast

 Now I get the img1(x5,y5) value and I plug it into img2(xx,yy) 

 

Example 1: Rotate an image.
Example 2: Reflection and Rotation of an image.



Back to SCO CODES page