Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ttk
spam
Commits
d33cc740
Commit
d33cc740
authored
Mar 23, 2021
by
Gustavo Pinzon
Browse files
bug on test for DirectionalErosion
parent
e0d48397
Pipeline
#63169
passed with stages
in 26 minutes and 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tools/tests/test_filters.py
View file @
d33cc740
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
__future__
import
print_function
import
unittest
...
...
@@ -67,8 +67,9 @@ class testAll(unittest.TestCase):
if
vect
[
0
]
<
0
:
vect
[:]
=-
1
*
vect
[:]
a
=
random
.
randrange
(
1
,
10
,
1
)
c
=
random
.
randrange
(
1
,
10
,
1
)
print
(
a
,
c
)
if
numpy
.
abs
(
a
-
c
)
<
2
:
a
=
a
*
2
maxDim
=
numpy
.
max
([
a
,
c
])
maxDim
=
numpy
.
max
([
a
+
10
,
c
+
10
])
imTest
=
spam
.
kalisphera
.
makeBlurryNoisySpheroid
([
maxDim
,
maxDim
,
maxDim
],
[
numpy
.
floor
(
maxDim
/
2
),
numpy
.
floor
(
maxDim
/
2
),
numpy
.
floor
(
maxDim
/
2
)],
[
a
,
c
],
...
...
@@ -79,14 +80,15 @@ class testAll(unittest.TestCase):
imEroded
=
morph
.
directionalErosion
(
imTest
,
vect
,
a
,
c
)
self
.
assertIs
(
imEroded
,
None
)
#Perform watershed to label the grains
labIm
=
ws
.
watershed
(
imTest
)
#CHANGE FOR scipy.ndimage.label
labIm
=
ws
.
watershed
(
imTest
)
#Perform directional erosion
imEroded
=
morph
.
directionalErosion
(
imTest
,
[
vect
],
a
,
c
)
#Label the markers
markers
,
num_seeds
=
scipy
.
ndimage
.
label
(
imEroded
,
structure
=
numpy
.
ones
((
3
,
3
,
3
)))
centerOfMassMarkers
=
scipy
.
ndimage
.
measurements
.
center_of_mass
(
markers
,
labels
=
markers
,
index
=
list
(
numpy
.
unique
(
markers
)[
1
:]))
#CHANGE FOR SPAM
#Check that the center of mass of the marker lies inside the labelled grain
self
.
assertEqual
(
labIm
[
int
(
centerOfMassMarkers
[
0
][
0
]),
int
(
centerOfMassMarkers
[
0
][
1
]),
int
(
centerOfMassMarkers
[
0
][
2
])],
numpy
.
unique
(
labIm
)[
1
])
# Label the markers
markers
=
spam
.
label
.
watershed
(
imEroded
)
# Compute COM
COM
=
spam
.
label
.
centresOfMass
(
markers
)
#Check that the center of mass of the marker lies inside the labelled grain
self
.
assertEqual
(
labIm
[
int
(
COM
[
1
][
0
]),
int
(
COM
[
1
][
1
]),
int
(
COM
[
1
][
2
])],
numpy
.
unique
(
labIm
)[
1
])
def
test_greyDilation
(
self
):
#Generate single sphere
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment