Skip to content

Commit

Permalink
Merge pull request #289 from clEsperanto/update-clic-0.15.1
Browse files Browse the repository at this point in the history
  • Loading branch information
StRigaud authored Nov 14, 2024
2 parents ed885f7 + 6cfbc00 commit 282ff74
Show file tree
Hide file tree
Showing 25 changed files with 2,128 additions and 2,170 deletions.
2,115 changes: 967 additions & 1,148 deletions pyclesperanto/_tier1.py

Large diffs are not rendered by default.

948 changes: 453 additions & 495 deletions pyclesperanto/_tier2.py

Large diffs are not rendered by default.

225 changes: 101 additions & 124 deletions pyclesperanto/_tier3.py

Large diffs are not rendered by default.

168 changes: 69 additions & 99 deletions pyclesperanto/_tier4.py

Large diffs are not rendered by default.

92 changes: 36 additions & 56 deletions pyclesperanto/_tier5.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@
from ._core import Device
from ._decorators import plugin_function

clic = importlib.import_module("._pyclesperanto", package="pyclesperanto")

clic = importlib.import_module('._pyclesperanto', package='pyclesperanto')

@plugin_function(categories=["combine"])
def array_equal(
input_image0: Image, input_image1: Image, device: Optional[Device] = None
input_image0: Image,
input_image1: Image,
device: Optional[Device] =None
) -> bool:
"""Compares if all pixels of two images are identical. If shape of the images or
any pixel are different, returns False. True otherwise This function is supposed
to work similarly like its counterpart in numpy [1].
Parameters
----------
input_image0: Image
input_image0: Image
First array to compare
input_image1: Image
input_image1: Image
Second array to compare
device: Optional[Device] (= None)
Device to perform the operation on.
Expand All @@ -42,30 +43,22 @@ def array_equal(
"""
return clic._array_equal(device, input_image0, input_image1)


@plugin_function(
categories=[
"label processing",
"combine labels",
"in assistant",
"bia-bob-suggestion",
]
)
@plugin_function(categories=["label processing", "combine labels", "in assistant", "bia-bob-suggestion"])
def combine_labels(
input_image0: Image,
input_image1: Image,
output_image: Optional[Image] = None,
device: Optional[Device] = None,
output_image: Optional[Image] =None,
device: Optional[Device] =None
) -> Image:
"""Combines two label images by adding labels of a given label image to another.
Labels in the second image overwrite labels in the first passed image.
Afterwards, labels are relabeled sequentially.
Parameters
----------
input_image0: Image
input_image0: Image
label image to add labels to.
input_image1: Image
input_image1: Image
label image to add labels from.
output_image: Optional[Image] (= None)
Output label image.
Expand All @@ -78,20 +71,19 @@ def combine_labels(
"""
return clic._combine_labels(device, input_image0, input_image1, output_image)


@plugin_function(categories=["label", "in assistant"])
def connected_components_labeling(
input_image: Image,
output_image: Optional[Image] = None,
connectivity: str = "box",
device: Optional[Device] = None,
output_image: Optional[Image] =None,
connectivity: str ='box',
device: Optional[Device] =None
) -> Image:
"""Performs connected components analysis inspecting the box neighborhood of every
pixel to a binary image and generates a label map.
Parameters
----------
input_image: Image
input_image: Image
Binary image to label.
output_image: Optional[Image] (= None)
Output label image.
Expand All @@ -108,24 +100,21 @@ def connected_components_labeling(
----------
[1] https://clij.github.io/clij2-docs/reference_connectedComponentsLabelingBox
"""
return clic._connected_components_labeling(
device, input_image, output_image, str(connectivity)
)

return clic._connected_components_labeling(device, input_image, output_image, str(connectivity))

@plugin_function(categories=["label", "in assistant", "bia-bob-suggestion"])
def connected_component_labeling(
input_image: Image,
output_image: Optional[Image] = None,
connectivity: str = "box",
device: Optional[Device] = None,
output_image: Optional[Image] =None,
connectivity: str ='box',
device: Optional[Device] =None
) -> Image:
"""Performs connected components analysis inspecting the box neighborhood of every
pixel to a binary image and generates a label map.
Parameters
----------
input_image: Image
input_image: Image
Binary image to label.
output_image: Optional[Image] (= None)
Output label image.
Expand All @@ -142,22 +131,19 @@ def connected_component_labeling(
----------
[1] https://clij.github.io/clij2-docs/reference_connectedComponentsLabelingBox
"""
return clic._connected_component_labeling(
device, input_image, output_image, str(connectivity)
)

return clic._connected_component_labeling(device, input_image, output_image, str(connectivity))

@plugin_function(categories=["label processing", "in assistant", "bia-bob-suggestion"])
def reduce_labels_to_centroids(
input_image: Image,
output_image: Optional[Image] = None,
device: Optional[Device] = None,
output_image: Optional[Image] =None,
device: Optional[Device] =None
) -> Image:
"""Take a label map and reduce each label to its centroid.
Parameters
----------
input_image: Image
input_image: Image
Label image to reduce.
output_image: Optional[Image] (= None)
Output label image with centroids.
Expand All @@ -174,20 +160,19 @@ def reduce_labels_to_centroids(
"""
return clic._reduce_labels_to_centroids(device, input_image, output_image)


@plugin_function(categories=["label processing", "in assistant"])
def filter_label_by_size(
input_image: Image,
output_image: Optional[Image] = None,
minimum_size: float = 0,
maximum_size: float = 100,
device: Optional[Device] = None,
output_image: Optional[Image] =None,
minimum_size: float =0,
maximum_size: float =100,
device: Optional[Device] =None
) -> Image:
"""Filter labelled objects outside of the min/max size range value.
Parameters
----------
input_image: Image
input_image: Image
Input label image.
output_image: Optional[Image] (= None)
Output label image.
Expand All @@ -206,24 +191,21 @@ 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(minimum_size), float(maximum_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,
minimum_size: float = 0,
maximum_size: float = 100,
device: Optional[Device] = None,
output_image: Optional[Image] =None,
minimum_size: float =0,
maximum_size: float =100,
device: Optional[Device] =None
) -> Image:
"""Filter labelled objects outside of the min/max size range value.
Parameters
----------
input_image: Image
input_image: Image
Input label image.
output_image: Optional[Image] (= None)
Output label image.
Expand All @@ -242,6 +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(minimum_size), float(maximum_size)
)
return clic._exclude_labels_outside_size_range(device, input_image, output_image, float(minimum_size), float(maximum_size))
Loading

0 comments on commit 282ff74

Please sign in to comment.