Program: TRANSFORM Purpose: Transform a (sub)set using rotation, scaling, translation etc. Category: MANIPULATION, MATH, UTILITY File: transform.c Author: M.G.R. Vogelaar Keywords: INSET= Give input set (,subsets) to transform: Maximum number of subsets is 2048. This set will be transformed to OUTSET=, using a concatenation of simple operations like rotation, scaling, translation etc. BOX= Give box in ..... [entire subset] Restrict operations to data within these limits. OUTSET= Give output set (, subsets): Output set and subset(s) for the result. The number of output subsets is the same as the number of input sub- sets. POS= Enter position of centre: [0,0] All operations are defined with respect to a central point. This point must be defined here. It can be entered in any coordinates (grids/physical). If, for example, you want to rotate an object about its centre, then determine the position of this centre (e.g. -6.2 8.5) and enter these numbers here (e.g. POS= -6.2 8.5). OPERATION= Enter sequence of operations: [2 (=rotation)] Identify operations by their numbers and enter one or more numbers. Numbers must be separated by spaces. The operations that define the transformation are started in the order as entered by the user. The maximum number of operations is 31. The operation menu as it will appear in the log-file: Operations: (With respect to POS=) =================================== 1. Translation 2. Rotation (counter clockwise) 3. Scaling 4. Reflection about x-axis 5. Reflection about y-axis 6. Reflection wrt. centre 7. X shear 8. Y shear Example: OPERATION=1 2 1 (=translation followed by rotation followed by translation) The following keywords are asked as many times as the corresponding operation is defined in OPERATION= If the same keyword is prompted more than once, an index number is inserted in the message to keep track of the operation that is involved. ======================================================= TRANSLXY= Enter translation in x and y: [0,0] Enter two numbers for a translation. The numbers need not to be integers. TRANSLXY=a b means: translate the image a grids in x and b grids in y. ANGLE= Enter rotation angle (deg): [0] Enter an angle in degrees. This will rotate the image with respect to the grids given in POS= or the position defined with a previous translation. The rotation is counter-clockwise. SCALEXY= Enter scaling in x and y: [1,1] Enter two numbers for a scaling. The numbers can be non-integer. A scaling is always with respect to the position in POS= or the position defined with a previous translation. XSHEAR= Enter shear factor in X: [0] Scale an image in X only with a factor that can be a non-integer number. The shear is always with respect to the position in POS= or the position defined with a previous translation. YSHEAR= Enter shear factor in Y: [0] See description at XSHEAR= Description: Sometimes it is handy to manipulate (test) data without using and changing a physical coordinate system. This program transforms data using simple linear transformations. If we represent these transformations by 3x3 matrices, then: | 1 0 0 | 1) Translation: | 0 1 0 | | Tx Ty 1 | | cos(t) sin(t) 0 | 2) Rotation (counter clockwise): |-sin(t) cos(t) 0 | | 0 0 1 | | Sx 0 0 | 3) Scaling: | 0 Sy 0 | | 0 0 1 | | 1 0 0 | 4) reflection (x-axis): | 0 -1 0 | | 0 0 1 | |-1 0 0 | 5) reflection (y-axis): | 0 1 0 | | 0 0 1 | |-1 0 0 | 6) reflection (POS=): | 0 -1 0 | | 0 0 1 | | 1 0 0 | 7) X shear: | S 1 0 | | 0 0 1 | | 1 S 0 | 8) Y shear: | 0 1 0 | | 0 0 1 | Operations are concatenated by multiplying matrices. A sequence of operations is automatically prepended by a translation of POS= to 0,0 and appended by a translation of 0,0 to POS= To get a regular sampling of output positions, this program has a loop that calculates for each position in the output, a corresponding position in the input using the inverse of the net-transformation matrix. This position is usually a non-integer position and we can use an interpolation in values of neighbouring pixels to get an image value for the output image. Blanks are recognized, but the interpolation will not increase the number of blanks. Notes: If the program transforms data in a way that not all positions have a counterpart within BOX= then these positions get a blank as image value in the output set. Example: ....... Updates: Aug 01, 1996: VOG, Document created. Sep 24, 1996: KGB, CPOS changed into POS. Feb 1, 2000: JPT, Increased number of subsets. Jul 27, 2000: VOG, Changed local 'getipval' to library interpol.