Commit 95c7909
committed
Fix three accuracy bugs in reproject resampling kernels (#1086)
1. Nearest-neighbor: use floor(r + 0.5) instead of int(r + 0.5) to
round correctly for negative fractional pixel coordinates.
int() truncates toward zero, which maps [-1.0, -0.5) to pixel 0
instead of out-of-bounds.
2. Cubic: check real neighbor indices against source bounds instead of
clamping OOB indices to the edge pixel. Border replication masked
the OOB condition, preventing the bilinear fallback that GDAL uses
when the 4x4 stencil extends outside the source.
3. CuPy map_coordinates fallback: tighten the NaN contamination
threshold from 0.1 to 1e-6 so that small NaN weights from distant
cubic neighbors are caught, matching the native CUDA kernel behavior.1 parent 268618d commit 95c7909
2 files changed
+78
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
59 | 54 | | |
60 | 55 | | |
61 | 56 | | |
| |||
109 | 104 | | |
110 | 105 | | |
111 | 106 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
117 | 110 | | |
118 | 111 | | |
119 | 112 | | |
120 | 113 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
127 | 118 | | |
128 | 119 | | |
129 | 120 | | |
| |||
339 | 330 | | |
340 | 331 | | |
341 | 332 | | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
352 | 338 | | |
353 | 339 | | |
354 | 340 | | |
| |||
453 | 439 | | |
454 | 440 | | |
455 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
456 | 447 | | |
457 | 448 | | |
458 | 449 | | |
| |||
844 | 835 | | |
845 | 836 | | |
846 | 837 | | |
847 | | - | |
| 838 | + | |
848 | 839 | | |
849 | 840 | | |
850 | 841 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
198 | 253 | | |
199 | 254 | | |
200 | 255 | | |
| |||
0 commit comments