<<prev file | next file >>    view single page | view frames    summary: fields | routine    details: routine

Interpolation/

square2quadrilateral.pro

warm (or map) a unit square onto an arbitrary quadrilateral according to the 4-point correspondences: (0,0) -> (x0,y0) (1,0) -> (x1,y1) (1,1) -> (x2,y2) (0,1) -> (x3,y3) The mapping is done using perspective transformation which preserve lines in all orientations and permit quadrilateral to quadrilateral mappings. see ref. bellow.

topsquare2quadrilateral image, grid manipulation

result = square2quadrilateral(x0in, y0in, x1in, y1in, x2in, y2in, x3in, y3in, xxin, yyin)

Return value

(2,n) array: the new coodinates (xout, yout) of the (xin,yin) point(s) after mapping. If xin is a scalar, then n is equal to the number of elements of x0. If xin is an array , then n is equal to the number of elements of xin. If xin and yin are omited, square2quadrilateral returns the matrix A which is used for the inverse transformation.

Parameters

x0in        in required

the coordinates of the quadrilateral (see above for correspondance with the unit square). Can be scalar or array. (x0,y0), (x1,y1), (x2,y2) and (x3,y3) are given in the anticlockwise order.

y0in        in required

the coordinates of the quadrilateral (see above for correspondance with the unit square). Can be scalar or array. (x0,y0), (x1,y1), (x2,y2) and (x3,y3) are given in the anticlockwise order.

x1in        in required

the coordinates of the quadrilateral (see above for correspondance with the unit square). Can be scalar or array. (x0,y0), (x1,y1), (x2,y2) and (x3,y3) are given in the anticlockwise order.

y1in        in required

the coordinates of the quadrilateral (see above for correspondance with the unit square). Can be scalar or array. (x0,y0), (x1,y1), (x2,y2) and (x3,y3) are given in the anticlockwise order.

x2in        in required

the coordinates of the quadrilateral (see above for correspondance with the unit square). Can be scalar or array. (x0,y0), (x1,y1), (x2,y2) and (x3,y3) are given in the anticlockwise order.

y2in        in required

the coordinates of the quadrilateral (see above for correspondance with the unit square). Can be scalar or array. (x0,y0), (x1,y1), (x2,y2) and (x3,y3) are given in the anticlockwise order.

x3in        in required

the coordinates of the quadrilateral (see above for correspondance with the unit square). Can be scalar or array. (x0,y0), (x1,y1), (x2,y2) and (x3,y3) are given in the anticlockwise order.

y3in        in required

the coordinates of the quadrilateral (see above for correspondance with the unit square). Can be scalar or array. (x0,y0), (x1,y1), (x2,y2) and (x3,y3) are given in the anticlockwise order.

xxin        in required

the coordinates of the point(s) for which we want to do the mapping. Can be scalar or array.

yyin        in required

the coordinates of the point(s) for which we want to do the mapping. Can be scalar or array.

Examples

IDL> res = square2quadrilateral(x0,y0,x1,y1,x2,y2,x3,y3[,xin,yin]) IDL> splot,[0,5],[0,3],/nodata,xstyle=1,ystyle=1 IDL> tracegrille, findgen(11)*.1, findgen(11)*.1,color=indgen(12)*20 IDL> xin = (findgen(11)*.1)#replicate(1, 11) IDL> yin = replicate(1, 11)#(findgen(11)*.1) IDL> out = square2quadrilateral(2,1,3,0,5,1,2,3, xin, yin) IDL> tracegrille, reform(out[0,*],11,11), reform(out[1,*],11,11),color=indgen(12)*20

Version history

History

Sebastien Masson (smasson@lodyc.jussieu.fr) August 2003 Based on "Digital Image Warping" by G. Wolberg IEEE Computer Society Press, Los Alamitos, California Chapter 3, see p 52-56

Known issues

Restrictions

I think degenerated quadrilateral (e.g. flat of twisted) is not work. This has to be tested.
Produced by IDLdoc 2.0.