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
2d20fef9
Commit
2d20fef9
authored
May 01, 2018
by
Emmanuel Roubin
Browse files
tests structuring elements
parent
dd4a8d70
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests/test_covariance.py
View file @
2d20fef9
...
...
@@ -17,9 +17,9 @@ class TestFonctionCov(unittest.TestCase):
def
test_alongAxis
(
self
):
im
=
tifffile
.
imread
(
"tools/data/snow/snow.tif"
)
c
=
cov
.
alongAxis
(
im
,
range
(
4
)
)
# c shoud be [[86833030. 74757580. 53643410. 35916468.] # axis 0
# [86833030. 76282920. 56910720. 39792388.] # axis 1
# [86833030. 76410500. 57040076. 39938920.]] # axis 2
# c shou
l
d be [[86833030. 74757580. 53643410. 35916468.] # axis 0
#
[86833030. 76282920. 56910720. 39792388.] # axis 1
#
[86833030. 76410500. 57040076. 39938920.]] # axis 2
self
.
assertAlmostEqual
(
sum
(
c
[:,
3
])
/
c
[
0
,
0
],
1.3318408137585245
,
places
=
5
)
def
test_subPixel
(
self
):
...
...
tests/test_mesh.py
0 → 100644
View file @
2d20fef9
# -*- coding: utf-8 -*-
from
__future__
import
print_function
import
unittest
import
os
import
tifffile
import
numpy
import
spam.mesh.structured
as
smesh
class
testAll
(
unittest
.
TestCase
):
def
tearDown
(
self
):
try
:
pass
except
OSError
:
pass
# tests structured meshes
def
test_structuringElement
(
self
):
a
=
smesh
.
structuringElement
(
radius
=
5
,
order
=
numpy
.
inf
,
margin
=
2
)
b
=
smesh
.
structuringElement
(
radius
=
7
,
order
=
2
,
margin
=
0
)
c
=
smesh
.
structuringElement
(
radius
=
8
,
order
=
1
,
margin
=
8
)
self
.
assertEqual
(
int
(
a
.
sum
()
+
len
(
a
)
+
b
.
sum
()
+
len
(
b
)
+
c
.
sum
()
+
len
(
c
)),
3646
)
if
__name__
==
'__main__'
:
unittest
.
main
()
tools/mesh/structured.py
View file @
2d20fef9
...
...
@@ -463,11 +463,11 @@ def structuringElement(radius=1, order=numpy.inf, margin=0, dim=3):
The structural element
"""
tb
=
tuple
([
2
*
radius
+
2
*
border
+
1
for
_
in
range
(
dim
)])
tb
=
tuple
([
2
*
radius
+
2
*
margin
+
1
for
_
in
range
(
dim
)])
ts
=
tuple
([
2
*
radius
+
1
for
_
in
range
(
dim
)])
c
=
numpy
.
abs
(
numpy
.
indices
(
ts
)
-
radius
)
d
=
numpy
.
zeros
(
tb
)
s
=
[
slice
(
border
,
border
+
2
*
radius
+
1
)
for
_
in
range
(
dim
)]
s
=
[
slice
(
margin
,
margin
+
2
*
radius
+
1
)
for
_
in
range
(
dim
)]
d
[
s
]
=
numpy
.
power
(
numpy
.
sum
(
numpy
.
power
(
c
,
order
),
axis
=
0
),
1.0
/
float
(
order
))
<=
radius
return
d
.
astype
(
'<u1'
)
...
...
Emmanuel Roubin
@roubine
mentioned in issue
#84 (closed)
·
May 01, 2018
mentioned in issue
#84 (closed)
mentioned in issue #84
Toggle commit list
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