Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering module - added reflect boundary fill #472

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b1aa869
Add filtering module for unwrapped interferogram
seyeonjeon Jun 5, 2024
99a431f
spelling error
seyeonjeon Jun 5, 2024
1cea785
spelling error
seyeonjeon Jun 5, 2024
d438c47
test_filtering.py added
seyeonjeon Jun 5, 2024
fbb885d
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
b539285
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
fc7594b
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
160bb69
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
f720c6f
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
3ee4134
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
bd57c61
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
883e7fc
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
ada2911
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
cfcf301
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
48b5935
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
10549fd
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
a8ecdf0
Update src/dolphin/filtering.py
seyeonjeon Jun 11, 2024
77ed078
Update tests/test_filtering.py
seyeonjeon Jun 11, 2024
e39225d
Update tests/test_filtering.py
seyeonjeon Jun 11, 2024
aeaf548
Apply suggestions from code review
scottstanie Jun 12, 2024
013d7ec
Update src/dolphin/filtering.py
scottstanie Jun 12, 2024
04b6f07
Merge branch 'filtering' of https://github.com/seyeonjeon/dolphin int…
Aug 30, 2024
1895572
Merge pull request #4 from isce-framework/main
seyeonjeon Sep 18, 2024
458f1d4
Merge branch 'isce-framework:main' into filtering
seyeonjeon Oct 14, 2024
5f0881c
Merge branch 'isce-framework:main' into filtering
seyeonjeon Oct 15, 2024
b01cd91
Merge branch 'filtering' of https://github.com/seyeonjeon/dolphin int…
Oct 15, 2024
07d9b5a
Merge branch 'filtering' of https://github.com/seyeonjeon/dolphin int…
Oct 15, 2024
85701d0
Update filtering.py
seyeonjeon Oct 30, 2024
de92763
change CRLF to LF
scottstanie Nov 22, 2024
1d22392
Merge branch 'main' into filtering
scottstanie Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion src/dolphin/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def filter_long_wavelength(
# Remove the plane, setting to 0 where we had no data for the plane fit:
unw_ifg_interp = np.where(total_valid_mask, unw0, plane)

# Fill the boundary area by reflecting pixel values
reflect_fill = _fill_boundary_area(unw_ifg_interp, in_bounds_pixels)

# Find the filter `sigma` which gives the correct cutoff in meters
sigma = _compute_filter_sigma(wavelength_cutoff, pixel_spacing, cutoff_value=0.5)

Expand All @@ -84,7 +87,7 @@ def filter_long_wavelength(
# See here for illustration of `mode="reflect"`
# https://scikit-image.org/docs/stable/auto_examples/transform/plot_edge_modes.html#interpolation-edge-modes
padded = np.pad(
unw_ifg_interp, ((pad_rows, pad_rows), (pad_cols, pad_cols)), mode="reflect"
reflect_fill, ((pad_rows, pad_rows), (pad_cols, pad_cols)), mode="reflect"
)

# Apply Gaussian filter
Expand All @@ -103,6 +106,44 @@ def filter_long_wavelength(
return filtered_ifg


def _fill_boundary_area(unw_ifg_interp: np.ndarray, mask: np.ndarray) -> np.ndarray:
"""Fill the boundary area by reflecting pixel values."""
# Rotate the data to align the frame
rt_unw_ifg = ndimage.rotate(unw_ifg_interp, 8.6, reshape=False)

rt_pad = 700 # Apply padding for rotating back
# Fill boundary area using np.pad for each horizontal step and
reflect_filled = np.pad(
rt_unw_ifg[846:6059, :],
((846, rt_unw_ifg.shape[0] - 6059), (0, 0)),
mode="reflect",
)
reflect_filled = np.pad(
reflect_filled[618:6241, :],
((618, rt_unw_ifg.shape[0] - 6241), (0, 0)),
mode="reflect",
)
reflect_filled = np.pad(
reflect_filled[399:6447, :],
((399 + rt_pad, rt_unw_ifg.shape[0] - 6447 + rt_pad), (0, 0)),
mode="reflect",
)
# Fill vertical boundary area using np.pad
reflect_filled = np.pad(
reflect_filled[:, 591:8861],
((0, 0), (591 + rt_pad, rt_unw_ifg.shape[1] - 8861 + rt_pad)),
mode="reflect",
)

# Rotate back to original angle
reflect_filled = ndimage.rotate(reflect_filled, -8.6, reshape=False)
reflect_filled = reflect_filled[rt_pad:-rt_pad, rt_pad:-rt_pad]
# Copy original in-bound pixels
reflect_filled[mask] = unw_ifg_interp[mask]

return reflect_filled


def _compute_filter_sigma(
wavelength_cutoff: float, pixel_spacing: float, cutoff_value: float = 0.5
) -> float:
Expand Down
Loading