-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from clEsperanto/release-0.11.0
Release 0.11.0
- Loading branch information
Showing
10 changed files
with
471 additions
and
4 deletions.
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import numpy as np | ||
from skimage.segmentation.morphsnakes import inf_sup, sup_inf | ||
|
||
import pyclesperanto as cle | ||
|
||
cle.select_device("TX") | ||
|
||
|
||
def test_inferior_superior_2d(): | ||
test = cle.push( | ||
np.asarray( | ||
[ | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 0, 0, 0, 0, 1, 1, 0], | ||
[0, 1, 1, 0, 0, 0, 0, 1, 1, 0], | ||
[0, 1, 1, 0, 0, 0, 0, 1, 1, 0], | ||
[0, 1, 1, 0, 0, 0, 0, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
] | ||
).astype(np.uint8) | ||
) | ||
|
||
reference = cle.push( | ||
np.asarray( | ||
[ | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0, 0, 1, 1, 1, 0], | ||
[0, 1, 1, 0, 0, 0, 0, 1, 1, 0], | ||
[0, 1, 1, 0, 0, 0, 0, 1, 1, 0], | ||
[0, 1, 1, 1, 0, 0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
] | ||
).astype(np.uint8) | ||
) | ||
|
||
result = cle.create(test) | ||
cle.binary_infsup(test, result) | ||
|
||
print(result) | ||
|
||
a = cle.pull(result) | ||
b = cle.pull(reference) | ||
assert np.array_equal(a, b) | ||
|
||
|
||
def test_inferior_superior_3d(): | ||
test = cle.push( | ||
np.asarray( | ||
[ | ||
[ | ||
[0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 0, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0], | ||
], | ||
] | ||
).astype(np.uint8) | ||
) | ||
|
||
reference = cle.push( | ||
np.asarray( | ||
[ | ||
[ | ||
[0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0], | ||
], | ||
[ | ||
[0, 0, 0, 0, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 1, 1, 1, 0], | ||
[0, 0, 0, 0, 0], | ||
], | ||
] | ||
).astype(np.uint8) | ||
) | ||
|
||
result = cle.create(test) | ||
cle.binary_infsup(test, result) | ||
|
||
print(result) | ||
|
||
a = cle.pull(result) | ||
b = cle.pull(reference) | ||
assert np.array_equal(a, b) |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import numpy as np | ||
from skimage import morphology, segmentation | ||
|
||
import pyclesperanto as cle | ||
|
||
# def test_morphological_chan_vese(): | ||
# image = generate_disk((25, 25), 5).astype(np.float32) | ||
# reference = cle.push(segmentation.morphological_chan_vese(image, num_iter=1, smoothing=1, lambda1=1, lambda2=1)) | ||
# result = cle.morphological_chan_vese(image, num_iter=1, smoothing=, lambda1=1, lambda2=1) | ||
# a = cle.pull(result).astype(np.uint8) | ||
# b = cle.pull(reference).astype(np.uint8) | ||
# print(a) | ||
# print(b) | ||
# assert (np.array_equal(a, b)) | ||
|
||
|
||
# def test_morphological_chan_vese_on_membranes_2d(): | ||
# from skimage.data import cells3d | ||
# from skimage.segmentation import morphological_chan_vese | ||
# import pyclesperanto as cle | ||
# image2d = cells3d()[30, 0, ...] | ||
# result_gpu = cle.morphological_chan_vese(image2d, num_iter=20, smoothing=10) | ||
# result_cpu = morphological_chan_vese(image2d, num_iter=20, smoothing=10) | ||
# assert cle.array_equal(result_cpu, result_gpu) | ||
|
||
# def test_morphological_chan_vese_on_membranes_3d(): | ||
# from skimage.data import cells3d | ||
# from skimage.segmentation import morphological_chan_vese | ||
# import pyclesperanto as cle | ||
# image3d = cells3d()[10:50:, 0, :40, :40] | ||
# result_gpu = cle.morphological_chan_vese(image3d, num_iter=20, smoothing=10) | ||
# result_cpu = morphological_chan_vese(image3d, num_iter=20, smoothing=10) | ||
# cle.array_equal(result_cpu, result_gpu) | ||
|
||
|
||
def generate_disk(shape, radius): | ||
image = np.zeros(shape) | ||
image[ | ||
image.shape[0] // 2 - radius : image.shape[0] // 2 + radius + 1, | ||
image.shape[1] // 2 - radius : image.shape[1] // 2 + radius + 1, | ||
] = morphology.disk(radius) | ||
return image |
Oops, something went wrong.