Commit dc9d6f6
committed
Warper: improve XSCALE/YSALE computation logic when the target shape is quite different from the source shape
The current logic to compute them is quite naive, and only reasonably
works when the shape of the output chunk is similar (in proportion and
orientation) to the one of the input chunk. Failing that, inappropriate
values are computed leading typically to blurring.
Rework the logic to be closer to a specific case that had already been
implemented to deal with discontinuities at the antimeridian, but with
modifications. So we compute the transformation of a maximum of 10x10
unit squares in the target pixel space to the source pixel space. If a
source polygon retains an approximative rectangular shape with modest
rotation, use the width/height of that rectangle to compute
XSCALE/YSCALE. Otherwise compute the area of the rectangle and make
XSCALE/YSCALE be the inverse of the square root of the area.
Average the values for each output polygon, except values that are less
than 10% of the maximum scale, to avoid issues with polar
discontinuities
Also revise the logic to decide whether we use a 4 input sample per output
pixel vs generalized resampling kernel for bilinear and bicubic.
Previously we only used the 4-sample formula if not downsampling (with a
margin error of 5%). Increase that tolerance to allow up to a 50%
downsampling. And emit a debug trace when the generalized formula is
used instead of the 4 sample one.
Due to those changes, a few existing expected checksums had to be
adjusted. And we also had to adjust a heuristics in the
average/mode/Q1/Q3/max/etc. resampling code path that dealt with
polar discontinuities to make a related test still pass.1 parent 3c5c592 commit dc9d6f6
File tree
9 files changed
+310
-223
lines changed- alg
- autotest
- alg
- data
- gcore
- gdrivers
- utilities
9 files changed
+310
-223
lines changedLarge diffs are not rendered by default.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2302 | 2302 | | |
2303 | 2303 | | |
2304 | 2304 | | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
| 488 | + | |
493 | 489 | | |
494 | 490 | | |
495 | 491 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2270 | 2270 | | |
2271 | 2271 | | |
2272 | 2272 | | |
2273 | | - | |
2274 | | - | |
2275 | | - | |
2276 | | - | |
2277 | | - | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
2278 | 2276 | | |
2279 | | - | |
2280 | | - | |
2281 | | - | |
2282 | | - | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
2283 | 2281 | | |
2284 | 2282 | | |
2285 | 2283 | | |
| |||
2295 | 2293 | | |
2296 | 2294 | | |
2297 | 2295 | | |
2298 | | - | |
| 2296 | + | |
2299 | 2297 | | |
2300 | | - | |
| 2298 | + | |
2301 | 2299 | | |
2302 | | - | |
2303 | | - | |
2304 | | - | |
2305 | | - | |
2306 | | - | |
2307 | | - | |
2308 | | - | |
2309 | | - | |
2310 | | - | |
2311 | | - | |
2312 | | - | |
2313 | | - | |
2314 | | - | |
2315 | | - | |
2316 | | - | |
2317 | | - | |
2318 | | - | |
2319 | | - | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
2320 | 2303 | | |
2321 | | - | |
2322 | | - | |
2323 | | - | |
2324 | | - | |
2325 | | - | |
2326 | | - | |
2327 | | - | |
2328 | | - | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
2329 | 2312 | | |
2330 | | - | |
2331 | | - | |
| 2313 | + | |
| 2314 | + | |
2332 | 2315 | | |
2333 | | - | |
| 2316 | + | |
| 2317 | + | |
2334 | 2318 | | |
2335 | | - | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
2336 | 2331 | | |
2337 | 2332 | | |
2338 | | - | |
2339 | | - | |
2340 | | - | |
2341 | | - | |
2342 | | - | |
2343 | | - | |
| 2333 | + | |
2344 | 2334 | | |
2345 | 2335 | | |
2346 | | - | |
2347 | | - | |
2348 | | - | |
2349 | | - | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
2350 | 2340 | | |
2351 | | - | |
2352 | | - | |
2353 | | - | |
2354 | | - | |
2355 | | - | |
2356 | | - | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
2357 | 2347 | | |
2358 | | - | |
2359 | | - | |
2360 | | - | |
2361 | | - | |
2362 | | - | |
2363 | | - | |
2364 | | - | |
2365 | | - | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
2366 | 2352 | | |
2367 | | - | |
2368 | 2353 | | |
| 2354 | + | |
2369 | 2355 | | |
2370 | 2356 | | |
2371 | 2357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1323 | 1323 | | |
1324 | 1324 | | |
1325 | 1325 | | |
1326 | | - | |
1327 | | - | |
1328 | | - | |
1329 | | - | |
1330 | | - | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
1331 | 1329 | | |
1332 | 1330 | | |
1333 | 1331 | | |
| |||
1363 | 1361 | | |
1364 | 1362 | | |
1365 | 1363 | | |
1366 | | - | |
1367 | | - | |
1368 | | - | |
1369 | | - | |
1370 | | - | |
| 1364 | + | |
1371 | 1365 | | |
1372 | 1366 | | |
1373 | 1367 | | |
| |||
1504 | 1498 | | |
1505 | 1499 | | |
1506 | 1500 | | |
1507 | | - | |
1508 | | - | |
1509 | | - | |
1510 | | - | |
1511 | | - | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
1512 | 1504 | | |
1513 | 1505 | | |
1514 | 1506 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2497 | 2497 | | |
2498 | 2498 | | |
2499 | 2499 | | |
2500 | | - | |
| 2500 | + | |
2501 | 2501 | | |
2502 | 2502 | | |
2503 | 2503 | | |
| |||
2646 | 2646 | | |
2647 | 2647 | | |
2648 | 2648 | | |
2649 | | - | |
| 2649 | + | |
2650 | 2650 | | |
2651 | 2651 | | |
2652 | 2652 | | |
| |||
0 commit comments