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
1beb281d
Commit
1beb281d
authored
Oct 29, 2020
by
Emmanuel Roubin
Browse files
Generalize covariance function to any image shapes
parent
dac97218
Pipeline
#51811
passed with stages
in 25 minutes and 12 seconds
Changes
2
Pipelines
5
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
1beb281d
...
...
@@ -63,3 +63,6 @@ ttkvenv
# latex
*.aux
*.log
# code OSS
.vscode
tools/measurements/covariance.py
View file @
1beb281d
...
...
@@ -84,7 +84,7 @@ def covarianceAlongAxis(im, d, mask=None, axis=[0, 1, 2]):
print
(
'spam.measurements.covariance.covarianceAlongAxis: d={}. Should be a list of integers.'
.
format
(
type
(
d
[
0
])))
print
(
'exit function.'
)
return
-
1
if
max
(
d
)
>=
im
.
shape
[
0
]
or
max
(
d
)
>=
im
.
shape
[
1
]
or
max
(
d
)
>=
im
.
shape
[
2
]
:
if
any
([
max
(
d
)
>=
im
.
shape
[
i
]
f
or
i
in
axis
])
:
print
(
'spam.measurements.covariance.covarianceAlongAxis: max(d)={}. Should be smaller than the image.'
.
format
(
max
(
d
)))
print
(
'exit function.'
)
return
-
1
...
...
@@ -115,8 +115,7 @@ def covarianceAlongAxis(im, d, mask=None, axis=[0, 1, 2]):
im_multi
=
numpy
.
multiply
(
im_multi
,
mask_eff
,
dtype
=
numpy
.
float32
)
else
:
# Step 2.1: Compute the pairs of numbers
size
=
im
.
shape
[
a
]
n
=
(
size
-
x
)
*
size
**
2
n
=
(
im
.
shape
[
a
]
-
x
)
*
numpy
.
prod
([
s
for
i
,
s
in
enumerate
(
im
.
shape
)
if
i
!=
a
])
#
# Step 2.2: Multiply the image
im_multi
=
numpy
.
multiply
(
im
,
spam
.
helpers
.
singleShift
(
im
,
x
,
a
,
sub
=
0
),
dtype
=
numpy
.
float32
)
# n_multi = numpy.sum(im_multi)
...
...
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