22 from __future__
import absolute_import, division, print_function
24 __all__ = [
"noDistort",
"linearXDistort",
"quadraticDistortX",
25 "cubicDistortX",
"manyTermX",
"crossTerms1",
26 "crossTerms2",
"crossTerms3",
"quadraticDistort",
27 "T2DistortX",
"T2DistortX"]
29 from builtins
import range
37 """Do no distortion. Used for sanity checking""" 39 out = src.table.copyRecord(src)
44 """Increase the x value in a Source object by frac. E.g 45 src.x = 1000 --> 1001 if frac=.001 49 frac How much to change X by 52 A deep copy of src, with the value of x changed 55 out = src.table.copyRecord(src)
56 out.set(out.table.getCentroidKey().getX(), out.getX()*(1+frac))
61 """Distort image by terms with power <=2 62 i.e y, y^2, x, xy, x^2 65 out = src.table.copyRecord(src)
70 out.set(out.table.getCentroidKey().getX(), x + val*frac)
71 out.set(out.table.getCentroidKey().getY(), y)
76 """Distort image by terms with power <=2 77 i.e y, y^2, x, xy, x^2 80 out = src.table.copyRecord(src)
85 out.set(out.table.getCentroidKey().getX(), x + val*frac)
86 out.set(out.table.getCentroidKey().getY(), y)
91 out = src.table.copyRecord(src)
94 val = x**3 - 2*x**2 + 4*x - 9
96 out.set(out.table.getCentroidKey().getX(), x + val*frac)
97 out.set(out.table.getCentroidKey().getY(), y)
102 """Increase the y value in a Source object by frac. E.g 103 src.x = 1000 --> 1001 if frac=.001 107 frac How much to change Y by 110 A deep copy of src, with the value of y changed 113 out = src.table.copyRecord(src)
114 out.set(out.table.getCentroidKey().getY(), out.getY()*(1+frac))
119 """Distort image by terms with power <=2 120 i.e y, y^2, x, xy, x^2 123 out = src.table.copyRecord(src)
128 out.set(out.table.getCentroidKey().getX(), x)
129 out.set(out.table.getCentroidKey().getY(), y + val*frac)
134 """Distort image by terms with power <=2 135 i.e y, y^2, x, xy, x^2 138 out = src.table.copyRecord(src)
143 out.set(out.table.getCentroidKey().getX(), x)
144 out.set(out.table.getCentroidKey().getY(), y + val*frac)
149 out = src.table.copyRecord(src)
152 val = y**3 - 2*y**2 + 4*y - 9
154 out.set(out.table.getCentroidKey().getX(), x)
155 out.set(out.table.getCentroidKey().getY(), y + val*frac)
160 out = src.table.copyRecord(src)
165 out.set(out.table.getCentroidKey().getX(), x)
166 out.set(out.table.getCentroidKey().getY(), y + val*frac)
171 out = src.table.copyRecord(src)
174 val = y**3 - 2*y**2 + 4*y - 9
176 out.set(out.table.getCentroidKey().getX(), x + val*frac)
177 out.set(out.table.getCentroidKey().getY(), y)
182 out = src.table.copyRecord(src)
185 valx = x**3 - 2*x**2 + 4*x - 9
186 valy = y**3 - 2*y**2 + 4*y - 9
188 out.set(out.table.getCentroidKey().getX(), x + valy*frac)
189 out.set(out.table.getCentroidKey().getY(), y + valx*frac)
194 """Distort image by terms with power <=2 195 i.e y, y^2, x, xy, x^2 198 out = src.table.copyRecord(src)
205 out.set(out.table.getCentroidKey().getX(), x + val*frac)
206 out.set(out.table.getCentroidKey().getY(), y)
211 """Distort image by a 2nd order Cheby polynomial""" 213 out = src.table.copyRecord(src)
216 out.set(out.table.getCentroidKey().getX(), x + frac*val)
221 """Create a copy of srcList, and apply function to distort the 225 srcList a SourceSet object 226 function: A function that does a deep copy of a single Source 232 out.append(function(src))
235 for i
in range(len(srcList)):
239 x1, y1 = s.getX(), s.getY()
240 x2, y2 = o.getX(), o.getY()
242 diff = math.hypot(x1-x2, y1-y2)
243 maxDiff = max(diff, maxDiff)
245 print(
"Max deviation is %e pixels" % (maxDiff))
def quadraticDistort(src, frac=1e-6)
def crossTerms3(src, frac=1e-9)
def manyTermX(src, frac=1e-9)
def manyTermY(src, frac=1e-9)
def cubicDistortY(src, frac=1e-9)
def cubicDistortX(src, frac=1e-9)
def crossTerms2(src, frac=1e-11)
def T2DistortX(src, frac=1e-6)
def linearXDistort(src, frac=.001)
def quadraticDistortX(src, frac=1e-6)
def quadraticDistortY(src, frac=1e-6)
def linearYDistort(src, frac=.001)
def crossTerms1(src, frac=1e-11)
def distortList(srcList, function)