Skip to content

Commit 8963aa5

Browse files
Revert cubic interpolation to Lanczos4 (no advancement from small kernel for complex terrains)
1 parent 4ce50f8 commit 8963aa5

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

insardev_pygmtsar/insardev_pygmtsar/Nisar_transform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ def _process_chunk_nisar(iy, ix, chunk_y, chunk_x, n_y, n_x,
101101
del slc_chunk
102102

103103
proj_re = cv2.remap(slc_re, inv_map_r, inv_map_a,
104-
interpolation=cv2.INTER_CUBIC,
104+
interpolation=cv2.INTER_LANCZOS4,
105105
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
106106
proj_im = cv2.remap(slc_im, inv_map_r, inv_map_a,
107-
interpolation=cv2.INTER_CUBIC,
107+
interpolation=cv2.INTER_LANCZOS4,
108108
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
109109
del slc_re, slc_im, inv_map_a, inv_map_r
110110

insardev_pygmtsar/insardev_pygmtsar/Satellite.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,15 @@ def geocode(self, transform: xr.Dataset, data: xr.DataArray,
518518
# Direct remap - no chunking needed
519519
if np.iscomplexobj(data_vals):
520520
grid_proj_re = cv2.remap(data_vals.real.astype(np.float32), inv_map_r, inv_map_a,
521-
interpolation=cv2.INTER_CUBIC,
521+
interpolation=cv2.INTER_LANCZOS4,
522522
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
523523
grid_proj_im = cv2.remap(data_vals.imag.astype(np.float32), inv_map_r, inv_map_a,
524-
interpolation=cv2.INTER_CUBIC,
524+
interpolation=cv2.INTER_LANCZOS4,
525525
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
526526
grid_proj = (grid_proj_re + 1j * grid_proj_im).astype(data.dtype)
527527
else:
528528
grid_proj = cv2.remap(data_vals.astype(np.float32), inv_map_r, inv_map_a,
529-
interpolation=cv2.INTER_CUBIC,
529+
interpolation=cv2.INTER_LANCZOS4,
530530
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
531531
else:
532532
# Chunked remap - split x dimension into minimal equal chunks
@@ -541,10 +541,10 @@ def geocode(self, transform: xr.Dataset, data: xr.DataArray,
541541
for idx in chunk_indices:
542542
x_slice = slice(idx[0], idx[-1] + 1)
543543
re_chunk = cv2.remap(data_re, inv_map_r[:, x_slice], inv_map_a[:, x_slice],
544-
interpolation=cv2.INTER_CUBIC,
544+
interpolation=cv2.INTER_LANCZOS4,
545545
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
546546
im_chunk = cv2.remap(data_im, inv_map_r[:, x_slice], inv_map_a[:, x_slice],
547-
interpolation=cv2.INTER_CUBIC,
547+
interpolation=cv2.INTER_LANCZOS4,
548548
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
549549
grid_proj[:, x_slice] = (re_chunk + 1j * im_chunk).astype(data.dtype)
550550
del data_re, data_im
@@ -554,7 +554,7 @@ def geocode(self, transform: xr.Dataset, data: xr.DataArray,
554554
for idx in chunk_indices:
555555
x_slice = slice(idx[0], idx[-1] + 1)
556556
grid_proj[:, x_slice] = cv2.remap(data_f32, inv_map_r[:, x_slice], inv_map_a[:, x_slice],
557-
interpolation=cv2.INTER_CUBIC,
557+
interpolation=cv2.INTER_LANCZOS4,
558558
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
559559
del data_f32
560560

insardev_pygmtsar/insardev_pygmtsar/utils_s1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,12 +1013,12 @@ def parse_aztime(aztime_str):
10131013
# Apply shift using OpenCV remap with Lanczos interpolation
10141014
slc_real_shifted = cv2.remap(slc_deramped.real,
10151015
map_x, map_y,
1016-
interpolation=cv2.INTER_CUBIC,
1016+
interpolation=cv2.INTER_LANCZOS4,
10171017
borderMode=cv2.BORDER_CONSTANT,
10181018
borderValue=0)
10191019
slc_imag_shifted = cv2.remap(slc_deramped.imag,
10201020
map_x, map_y,
1021-
interpolation=cv2.INTER_CUBIC,
1021+
interpolation=cv2.INTER_LANCZOS4,
10221022
borderMode=cv2.BORDER_CONSTANT,
10231023
borderValue=0)
10241024
del slc_deramped, map_x, map_y

insardev_pygmtsar/insardev_pygmtsar/utils_satellite.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,7 +2334,7 @@ def remap_radar_to_geo(data, azi_map, rng_map, out_y, out_x):
23342334
23352335
Notes
23362336
-----
2337-
- Uses cv2.INTER_CUBIC for high-quality resampling
2337+
- Uses cv2.INTER_LANCZOS4 (8x8 Lanczos) for high-quality SLC resampling
23382338
- Pixels outside the radar coverage are filled with NaN
23392339
- For grids wider than 32766 pixels, processes in x-chunks
23402340
"""
@@ -2357,15 +2357,15 @@ def remap_radar_to_geo(data, azi_map, rng_map, out_y, out_x):
23572357
# Fast path: single cv2.remap call
23582358
if np.iscomplexobj(data_vals):
23592359
grid_proj_re = cv2.remap(data_vals.real.astype(np.float32), inv_map_r, inv_map_a,
2360-
interpolation=cv2.INTER_CUBIC,
2360+
interpolation=cv2.INTER_LANCZOS4,
23612361
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
23622362
grid_proj_im = cv2.remap(data_vals.imag.astype(np.float32), inv_map_r, inv_map_a,
2363-
interpolation=cv2.INTER_CUBIC,
2363+
interpolation=cv2.INTER_LANCZOS4,
23642364
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
23652365
grid_proj = (grid_proj_re + 1j * grid_proj_im).astype(data.dtype)
23662366
else:
23672367
grid_proj = cv2.remap(data_vals.astype(np.float32), inv_map_r, inv_map_a,
2368-
interpolation=cv2.INTER_CUBIC,
2368+
interpolation=cv2.INTER_LANCZOS4,
23692369
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
23702370
else:
23712371
# Chunked path: work around OpenCV's 32k pixel limit
@@ -2380,10 +2380,10 @@ def remap_radar_to_geo(data, azi_map, rng_map, out_y, out_x):
23802380
for idx in chunk_indices:
23812381
x_slice = slice(idx[0], idx[-1] + 1)
23822382
re_chunk = cv2.remap(data_re, inv_map_r[:, x_slice], inv_map_a[:, x_slice],
2383-
interpolation=cv2.INTER_CUBIC,
2383+
interpolation=cv2.INTER_LANCZOS4,
23842384
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
23852385
im_chunk = cv2.remap(data_im, inv_map_r[:, x_slice], inv_map_a[:, x_slice],
2386-
interpolation=cv2.INTER_CUBIC,
2386+
interpolation=cv2.INTER_LANCZOS4,
23872387
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
23882388
grid_proj[:, x_slice] = (re_chunk + 1j * im_chunk).astype(data.dtype)
23892389
del data_re, data_im
@@ -2393,7 +2393,7 @@ def remap_radar_to_geo(data, azi_map, rng_map, out_y, out_x):
23932393
for idx in chunk_indices:
23942394
x_slice = slice(idx[0], idx[-1] + 1)
23952395
grid_proj[:, x_slice] = cv2.remap(data_f32, inv_map_r[:, x_slice], inv_map_a[:, x_slice],
2396-
interpolation=cv2.INTER_CUBIC,
2396+
interpolation=cv2.INTER_LANCZOS4,
23972397
borderMode=cv2.BORDER_CONSTANT, borderValue=np.nan)
23982398
del data_f32
23992399

0 commit comments

Comments
 (0)