-
Notifications
You must be signed in to change notification settings - Fork 19
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
Closed
+42
−1
Closed
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 99a431f
spelling error
seyeonjeon 1cea785
spelling error
seyeonjeon d438c47
test_filtering.py added
seyeonjeon fbb885d
Update src/dolphin/filtering.py
seyeonjeon b539285
Update src/dolphin/filtering.py
seyeonjeon fc7594b
Update src/dolphin/filtering.py
seyeonjeon 160bb69
Update src/dolphin/filtering.py
seyeonjeon f720c6f
Update src/dolphin/filtering.py
seyeonjeon 3ee4134
Update src/dolphin/filtering.py
seyeonjeon bd57c61
Update src/dolphin/filtering.py
seyeonjeon 883e7fc
Update src/dolphin/filtering.py
seyeonjeon ada2911
Update src/dolphin/filtering.py
seyeonjeon cfcf301
Update src/dolphin/filtering.py
seyeonjeon 48b5935
Update src/dolphin/filtering.py
seyeonjeon 10549fd
Update src/dolphin/filtering.py
seyeonjeon a8ecdf0
Update src/dolphin/filtering.py
seyeonjeon 77ed078
Update tests/test_filtering.py
seyeonjeon e39225d
Update tests/test_filtering.py
seyeonjeon aeaf548
Apply suggestions from code review
scottstanie 013d7ec
Update src/dolphin/filtering.py
scottstanie 04b6f07
Merge branch 'filtering' of https://github.com/seyeonjeon/dolphin int…
1895572
Merge pull request #4 from isce-framework/main
seyeonjeon 458f1d4
Merge branch 'isce-framework:main' into filtering
seyeonjeon 5f0881c
Merge branch 'isce-framework:main' into filtering
seyeonjeon b01cd91
Merge branch 'filtering' of https://github.com/seyeonjeon/dolphin int…
07d9b5a
Merge branch 'filtering' of https://github.com/seyeonjeon/dolphin int…
85701d0
Update filtering.py
seyeonjeon de92763
change CRLF to LF
scottstanie 1d22392
Merge branch 'main' into filtering
scottstanie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
||
|
@@ -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 | ||
|
@@ -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", | ||
) | ||
Comment on lines
+114
to
+136
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for these numbers, we'll want to note the assumptions behind them
|
||
|
||
# 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: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll want a parameter for the rotation in degrees:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll also probably want some parameter to indicate wither there's any fill requested at all- a radar image filled all the way to the borders doesn't need this reflection