Skip to content

Commit

Permalink
Merge pull request #257 from clEsperanto/update-clic-0.13.4
Browse files Browse the repository at this point in the history
  • Loading branch information
StRigaud authored Oct 15, 2024
2 parents 8d64ed8 + a30bdc3 commit 0f1e0f5
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
python-version: ["3.11"]
platform: [ubuntu-latest, macos-latest] #, windows-latest]
defaults:
run:
Expand All @@ -31,7 +31,6 @@ jobs:
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: test
use-mamba: true
Expand Down
20 changes: 10 additions & 10 deletions pyclesperanto/_tier5.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def reduce_labels_to_centroids(
def filter_label_by_size(
input_image: Image,
output_image: Optional[Image] =None,
min_size: float =0,
max_size: float =100,
minimum_size: float =0,
maximum_size: float =100,
device: Optional[Device] =None
) -> Image:
"""Filter labelled objects outside of the min/max size range value.
Expand All @@ -176,9 +176,9 @@ def filter_label_by_size(
Input label image.
output_image: Optional[Image] (= None)
Output label image.
min_size: float (= 0)
minimum_size: float (= 0)
Minimum size of labels to keep.
max_size: float (= 100)
maximum_size: float (= 100)
Maximum size of labels to keep.
device: Optional[Device] (= None)
Device to perform the operation on.
Expand All @@ -191,14 +191,14 @@ def filter_label_by_size(
----------
[1] https://clij.github.io/clij2-docs/reference_excludeLabelsOutsideSizeRange
"""
return clic._filter_label_by_size(device, input_image, output_image, float(min_size), float(max_size))
return clic._filter_label_by_size(device, input_image, output_image, float(minimum_size), float(maximum_size))

@plugin_function(categories=["label processing", "in assistant"])
def exclude_labels_outside_size_range(
input_image: Image,
output_image: Optional[Image] =None,
min_size: float =0,
max_size: float =100,
minimum_size: float =0,
maximum_size: float =100,
device: Optional[Device] =None
) -> Image:
"""Filter labelled objects outside of the min/max size range value.
Expand All @@ -209,9 +209,9 @@ def exclude_labels_outside_size_range(
Input label image.
output_image: Optional[Image] (= None)
Output label image.
min_size: float (= 0)
minimum_size: float (= 0)
Minimum size of labels to keep.
max_size: float (= 100)
maximum_size: float (= 100)
Maximum size of labels to keep.
device: Optional[Device] (= None)
Device to perform the operation on.
Expand All @@ -224,4 +224,4 @@ def exclude_labels_outside_size_range(
----------
[1] https://clij.github.io/clij2-docs/reference_excludeLabelsOutsideSizeRange
"""
return clic._exclude_labels_outside_size_range(device, input_image, output_image, float(min_size), float(max_size))
return clic._exclude_labels_outside_size_range(device, input_image, output_image, float(minimum_size), float(maximum_size))
24 changes: 12 additions & 12 deletions pyclesperanto/_tier6.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def voronoi_labeling(
def remove_small_labels(
input_image: Image,
output_image: Optional[Image] =None,
min_size: float =100,
minimum_size: float =100,
device: Optional[Device] =None
) -> Image:
"""Removes labelled objects small than a given size (in pixels) from a label map.
Expand All @@ -185,7 +185,7 @@ def remove_small_labels(
Label image to filter.
output_image: Optional[Image] (= None)
Output label image fitlered.
min_size: float (= 100)
minimum_size: float (= 100)
Smallest size object allowed.
device: Optional[Device] (= None)
Device to perform the operation on.
Expand All @@ -198,13 +198,13 @@ def remove_small_labels(
----------
[1] https://clij.github.io/clij2-docs/reference_excludeLabelsOutsideSizeRange
"""
return clic._remove_small_labels(device, input_image, output_image, float(min_size))
return clic._remove_small_labels(device, input_image, output_image, float(minimum_size))

@plugin_function(categories=["label processing", "in assistant"])
def exclude_small_labels(
input_image: Image,
output_image: Optional[Image] =None,
max_size: float =100,
maximum_size: float =100,
device: Optional[Device] =None
) -> Image:
"""Removes labels from a label map which are below a given maximum size.
Expand All @@ -215,7 +215,7 @@ def exclude_small_labels(
Label image to filter.
output_image: Optional[Image] (= None)
Output label image fitlered.
max_size: float (= 100)
maximum_size: float (= 100)
Largest size object to exclude.
device: Optional[Device] (= None)
Device to perform the operation on.
Expand All @@ -228,13 +228,13 @@ def exclude_small_labels(
----------
[1] https://clij.github.io/clij2-docs/reference_excludeLabelsOutsideSizeRange
"""
return clic._exclude_small_labels(device, input_image, output_image, float(max_size))
return clic._exclude_small_labels(device, input_image, output_image, float(maximum_size))

@plugin_function(categories=["label processing", "in assistant", "bia-bob-suggestion"])
def remove_large_labels(
input_image: Image,
output_image: Optional[Image] =None,
max_size: float =100,
maximum_size: float =100,
device: Optional[Device] =None
) -> Image:
"""Removes labelled objects bigger than a given size (in pixels) from a label map.
Expand All @@ -245,7 +245,7 @@ def remove_large_labels(
Label image to filter.
output_image: Optional[Image] (= None)
Output label image fitlered.
max_size: float (= 100)
maximum_size: float (= 100)
Biggest size object allowed.
device: Optional[Device] (= None)
Device to perform the operation on.
Expand All @@ -258,13 +258,13 @@ def remove_large_labels(
----------
[1] https://clij.github.io/clij2-docs/reference_excludeLabelsOutsideSizeRange
"""
return clic._remove_large_labels(device, input_image, output_image, float(max_size))
return clic._remove_large_labels(device, input_image, output_image, float(maximum_size))

@plugin_function(categories=["label processing", "in assistant"])
def exclude_large_labels(
input_image: Image,
output_image: Optional[Image] =None,
min_size: float =100,
minimum_size: float =100,
device: Optional[Device] =None
) -> Image:
"""Removes labels from a label map which are higher a given minimum size.
Expand All @@ -275,7 +275,7 @@ def exclude_large_labels(
Label image to filter.
output_image: Optional[Image] (= None)
Output label image fitlered.
min_size: float (= 100)
minimum_size: float (= 100)
Smallest size object to keep.
device: Optional[Device] (= None)
Device to perform the operation on.
Expand All @@ -288,4 +288,4 @@ def exclude_large_labels(
----------
[1] https://clij.github.io/clij2-docs/reference_excludeLabelsOutsideSizeRange
"""
return clic._exclude_large_labels(device, input_image, output_image, float(min_size))
return clic._exclude_large_labels(device, input_image, output_image, float(minimum_size))
4 changes: 2 additions & 2 deletions pyclesperanto/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = "0.13.3"
CLIC_VERSION = "0.13.3"
VERSION = "0.13.4"
CLIC_VERSION = "0.13.4"
COMMON_ALIAS = "cle"
4 changes: 2 additions & 2 deletions src/wrapper/tier5_.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ m.def("_array_equal", &cle::tier5::array_equal_func, "Call cle::tier5::array_equ

m.def("_filter_label_by_size", &cle::tier5::filter_label_by_size_func, "Call cle::tier5::filter_label_by_size_func from C++ CLIc.",
py::return_value_policy::take_ownership,
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("min_size"), py::arg("max_size"));
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("minimum_size"), py::arg("maximum_size"));

m.def("_exclude_labels_outside_size_range", &cle::tier5::exclude_labels_outside_size_range_func, "Call cle::tier5::exclude_labels_outside_size_range_func from C++ CLIc.",
py::return_value_policy::take_ownership,
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("min_size"), py::arg("max_size"));
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("minimum_size"), py::arg("maximum_size"));
}
8 changes: 4 additions & 4 deletions src/wrapper/tier6_.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ m.def("_dilate_labels", &cle::tier6::dilate_labels_func, "Call cle::tier6::dilat

m.def("_remove_small_labels", &cle::tier6::remove_small_labels_func, "Call cle::tier6::remove_small_labels_func from C++ CLIc.",
py::return_value_policy::take_ownership,
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("min_size"));
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("minimum_size"));

m.def("_exclude_small_labels", &cle::tier6::exclude_small_labels_func, "Call cle::tier6::exclude_small_labels_func from C++ CLIc.",
py::return_value_policy::take_ownership,
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("max_size"));
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("maximum_size"));

m.def("_remove_large_labels", &cle::tier6::remove_large_labels_func, "Call cle::tier6::remove_large_labels_func from C++ CLIc.",
py::return_value_policy::take_ownership,
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("max_size"));
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("maximum_size"));

m.def("_exclude_large_labels", &cle::tier6::exclude_large_labels_func, "Call cle::tier6::exclude_large_labels_func from C++ CLIc.",
py::return_value_policy::take_ownership,
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("min_size"));
py::arg("device"), py::arg("src"), py::arg("dst"), py::arg("minimum_size"));
}
6 changes: 3 additions & 3 deletions tests/test_filter_labels_by_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_exclude_labels_out_of_size_range_2d():
)
)

gpu_output = cle.filter_label_by_size(gpu_input, min_size=4, max_size=5)
gpu_output = cle.filter_label_by_size(gpu_input, minimum_size=4, maximum_size=5)

a = cle.pull(gpu_output)
b = cle.pull(gpu_reference)
Expand Down Expand Up @@ -64,7 +64,7 @@ def test_exclude_small_labels_2d():
)
)

gpu_output = cle.exclude_small_labels(gpu_input, max_size=5)
gpu_output = cle.exclude_small_labels(gpu_input, maximum_size=5)

a = cle.pull(gpu_output)
b = cle.pull(gpu_reference)
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_exclude_large_labels_2d():
)
)

gpu_output = cle.exclude_large_labels(gpu_input, min_size=3)
gpu_output = cle.exclude_large_labels(gpu_input, minimum_size=3)

a = cle.pull(gpu_output)
b = cle.pull(gpu_reference)
Expand Down
15 changes: 15 additions & 0 deletions tests/test_threshold_otsu.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,18 @@ def test_threshold_otsu_against_scikit_image():

# compare
assert np.allclose(binary, (cle.pull(gpu_binary) > 0))



def test_threshold_otsu_low_values():
input = np.asarray([[0,0,0],
[0,0.003,0],
[0,0,0]])

reference = np.asarray([[0,0,0],
[0,1,0],
[0,0,0]])

result = cle.threshold_otsu(input)

assert np.allclose(reference, cle.pull(result) > 0)

0 comments on commit 0f1e0f5

Please sign in to comment.