Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
XRD
darfix
Commits
040c4edd
Commit
040c4edd
authored
Jun 17, 2021
by
Julia Garriga Ferrer
Browse files
[core][imageregistration] Update h values
parent
b8944c75
Changes
1
Hide whitespace changes
Inline
Side-by-side
darfix/core/imageRegistration.py
View file @
040c4edd
...
...
@@ -26,7 +26,7 @@
__authors__
=
[
"J. Garriga"
]
__license__
=
"MIT"
__date__
=
"1
6
/06/2021"
__date__
=
"1
7
/06/2021"
import
enum
...
...
@@ -195,8 +195,9 @@ def improve_linear_shift(data, v, h, epsilon, steps, nimages=None, shift_approac
iData
=
numpy
.
random
.
choice
(
iData
,
nimages
,
False
)
score
=
{}
utils
.
advancement_display
(
0
,
2
*
epsilon
,
"Finding shift"
)
for
h_
in
numpy
.
arange
(
h
-
epsilon
,
h
+
epsilon
,
2
*
epsilon
/
steps
):
utils
.
advancement_display
(
0
,
h
+
epsilon
,
"Finding shift"
)
step
=
2
*
epsilon
/
steps
for
h_
in
numpy
.
arange
(
0
,
h
+
epsilon
,
step
):
result
=
numpy
.
zeros
(
data
[
0
].
shape
)
for
iFrame
in
iData
:
shift
=
h_
*
v
*
iFrame
...
...
@@ -205,12 +206,12 @@ def improve_linear_shift(data, v, h, epsilon, steps, nimages=None, shift_approac
# Compute score using normalized variance
# TODO: add more autofocus options
score
[
h_
]
=
normalized_variance
(
result
)
utils
.
advancement_display
(
h_
-
epsilon
,
2
*
epsilon
,
"Finding shift"
)
utils
.
advancement_display
(
h_
+
step
,
h
+
epsilon
,
"Finding shift"
)
optimal_h
=
max
(
score
.
keys
(),
key
=
(
lambda
k
:
score
[
k
]))
return
optimal_h
def
shift_detection
(
data
,
h_max
=
0.5
,
steps
=
1000
,
shift_approach
=
"linear"
):
def
shift_detection
(
data
,
steps
,
shift_approach
=
"linear"
):
"""
Finds the linear shift from a set of images.
...
...
@@ -233,7 +234,7 @@ def shift_detection(data, h_max=0.5, steps=1000, shift_approach="linear"):
v
=
normalize
(
shift
)
v_
=
2
*
shift
/
len
(
data
)
h
=
numpy
.
sqrt
(
v_
[
0
]
**
2
+
v_
[
1
]
**
2
)
epsilon
=
0.5
*
h
epsilon
=
2
*
h
h
=
improve_linear_shift
(
data
,
v
,
h
,
epsilon
,
steps
,
shift_approach
=
shift_approach
)
return
numpy
.
outer
(
h
*
v
,
numpy
.
arange
(
len
(
data
)))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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