Skip to content

Commit

Permalink
decorated filtering functions with keep_names wrapper to make sure ba…
Browse files Browse the repository at this point in the history
…nd naming is consistent between input/output
  • Loading branch information
KMarkert committed Oct 8, 2021
1 parent ddf64f6 commit 0913030
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hydrafloods/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from hydrafloods import geeutils, decorators


@decorators.keep_names
@decorators.keep_attrs
def lee_sigma(img, window=9, sigma=0.9, looks=4, tk=7, keep_bands=["angle"]):
"""Lee Sigma speckle filtering algorithm.
Expand Down Expand Up @@ -128,6 +129,7 @@ def lee_sigma(img, window=9, sigma=0.9, looks=4, tk=7, keep_bands=["angle"]):


# The RL speckle filter
@decorators.keep_names
@decorators.keep_attrs
def refined_lee(image, keep_bands=["angle"]):
"""Refined Lee speckle filtering algorithm.
Expand Down Expand Up @@ -342,6 +344,7 @@ def apply_filter(b):
return output


@decorators.keep_names
@decorators.keep_attrs
def gamma_map(img, window=7, enl=4.9, keep_bands=["angle"]):
"""Gamma Map speckle filtering algorithm.
Expand Down Expand Up @@ -432,6 +435,7 @@ def gamma_map(img, window=7, enl=4.9, keep_bands=["angle"]):
return output


@decorators.keep_names
@decorators.keep_attrs
def p_median(img, window=5, keep_bands=["angle"]):
"""P-Median filter for smoothing imagery.
Expand Down Expand Up @@ -483,6 +487,7 @@ def _band_filter(bname):
return reduced_bands.rename(band_names)


@decorators.keep_names
@decorators.keep_attrs
def perona_malik(img, n_iters=10, K=3, method=1):
"""Perona-Malik (anisotropic diffusion) convolution
Expand Down Expand Up @@ -560,6 +565,7 @@ def _method_2(dI_W, dI_E, dI_N, dI_S):
return img


@decorators.keep_names
@decorators.keep_attrs
def open_binary(img, window=3, neighborhood=None):
"""Opening morphological filter. Opening is the dilation of the erosion of
Expand Down Expand Up @@ -588,6 +594,7 @@ def open_binary(img, window=3, neighborhood=None):
return opened


@decorators.keep_names
@decorators.keep_attrs
def close_binary(img, window=3, neighborhood=None):
"""Closing morphological filter. Closing is the erosion of the dialiation of
Expand Down

0 comments on commit 0913030

Please sign in to comment.