1mlib_ImagePolynomialWarp(3MmLeIdBi)aLib Library Functmiloinbs_ImagePolynomialWarp(3MLIB)
2
3
4
6 mlib_ImagePolynomialWarp - polynomial-based image warp
7
9 cc [ flag... ] file... -lmlib [ library... ]
10 #include <mlib.h>
11
12 mlib_status mlib_ImagePolynomialWarp(mlib_image *dst,
13 const mlib_image *src, const mlib_d64 *xCoeffs,
14 const mlib_d64 *yCoeffs, mlib_s32 n, mlib_d64 preShiftX,
15 mlib_d64 preShiftY, mlib_d64 postShiftX, mlib_d64 postShiftY,
16 mlib_d64 preScaleX, mlib_d64 preScaleY, mlib_d64 postScaleX,
17 mlib_d64 postScaleY, mlib_filter filter, mlib_edge edge);
18
19
21 The mlib_ImagePolynomialWarp() function performs a polynomial-based
22 image warp.
23
24
25 The images must have the same type, and the same number of channels.
26 The images can have 1, 2, 3, or 4 channels. The data type of the images
27 can be MLIB_BYTE, MLIB_SHORT, MLIB_USHORT, or MLIB_INT. The source and
28 destination images may have different sizes.
29
30
31 The xCoeffs and yCoeffs parameters must contain the same number of
32 coefficients of the form (n + 1)(n + 2)/2 for some n, where n is the
33 degree power of the polynomial. The coefficients, in order, are associ‐
34 ated with the terms:
35
36 1, x, y, x**2, x*y, y**2, ...,
37 x**n, x**(n-1)*y, ..., x*y**(n-1), y**n
38
39
40
41 and coefficients of value 0 cannot be omitted.
42
43
44 The image pixels are assumed to be centered at .5 coordinate points. In
45 other words, the upper-left corner pixel of an image is located at
46 (0.5, 0.5).
47
48
49 For each pixel in the destination image, its center point D is backward
50 mapped to a point S in the source image. Then the source pixels with
51 their centers surrounding point S are selected to do one of the inter‐
52 polations specified by the filter parameter to generate the pixel value
53 for point D.
54
55
56 The mapping is defined by the two bivariate polynomial functions X(x,
57 y) and Y(x, y) that map destination (x, y) coordinates to source X and
58 Y positions respectively.
59
60
61 The functions X(x, y) and Y(x, y) are:
62
63 preX = (x + preShiftX)*preScaleX
64
65 preY = (y + preShiftY)*preScaleY
66
67 n i
68 warpedX = SUM {SUM {xCoeffs_ij * preX**(i-j) * preY**j}}
69 i=0 j=0
70
71 n i
72 warpedY = SUM {SUM {yCoeffs_ij * preX**(i-j) * preY**j}}
73 i=0 j=0
74
75 X(x, y) = warpedX*postScaleX - postShiftX
76
77 Y(x, y) = warpedY*postScaleY - postShiftY
78
79
80
81 The destination (x, y) coordinates are pre-shifted by (preShiftX,
82 preShiftY) and pre-scaled by the factors preScaleX and preScaleY prior
83 to the evaluation of the polynomial. The results of the polynomial
84 evaluations are scaled by postScaleX and postScaleY, and then shifted
85 by (-postShiftX, -postShiftY) to produce the source pixel coordinates.
86 This process allows for better precision of the results and supports
87 tiled images.
88
90 The function takes the following arguments:
91
92 dst Pointer to destination image.
93
94
95 src Pointer to source image.
96
97
98 xCoeffs Destination to source transform coefficients for the X
99 coordinate.
100
101
102 yCoeffs Destination to source transform coefficients for the Y
103 coordinate.
104
105
106 n Degree power of the polynomial.
107
108
109 preShiftX Displacement to apply to destination X positions.
110
111
112 preShiftY Displacement to apply to destination Y positions.
113
114
115 postShiftX Displacement to apply to source X positions.
116
117
118 postShiftY Displacement to apply to source Y positions.
119
120
121 preScaleX Scale factor to apply to destination X positions.
122
123
124 preScaleY Scale factor to apply to destination Y positions.
125
126
127 postScaleX Scale factor to apply to source X positions.
128
129
130 postScaleY Scale factor to apply to source Y positions.
131
132
133 filter Type of resampling filter. It can be one of the follow‐
134 ing:
135
136 MLIB_NEAREST
137 MLIB_BILINEAR
138 MLIB_BICUBIC
139 MLIB_BICUBIC2
140
141
142
143 edge Type of edge condition. It can be one of the following:
144
145 MLIB_EDGE_DST_NO_WRITE
146 MLIB_EDGE_SRC_PADDED
147
148
149
151 The function returns MLIB_SUCCESS if successful. Otherwise it returns
152 MLIB_FAILURE.
153
155 See attributes(5) for descriptions of the following attributes:
156
157
158
159
160 ┌─────────────────────────────┬─────────────────────────────┐
161 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
162 ├─────────────────────────────┼─────────────────────────────┤
163 │Interface Stability │Committed │
164 ├─────────────────────────────┼─────────────────────────────┤
165 │MT-Level │MT-Safe │
166 └─────────────────────────────┴─────────────────────────────┘
167
169 mlib_ImagePolynomialWarp_Fp(3MLIB), mlib_ImagePolynomialWarpT‐
170 able(3MLIB), mlib_ImagePolynomialWarpTable_Fp(3MLIB), attributes(5)
171
172
173
174SunOS 5.11 2 Mar 2007 mlib_ImagePolynomialWarp(3MLIB)