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
tomotools
Nabu
Commits
3a1bfdd8
Commit
3a1bfdd8
authored
Jun 24, 2020
by
myron
Browse files
set default data type to np.float32
parent
00a34bc6
Pipeline
#28121
passed with stages
in 2 minutes and 53 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nabu/preproc/alignment.py
View file @
3a1bfdd8
...
...
@@ -49,7 +49,7 @@ except ImportError:
class
AlignmentBase
(
object
):
def
__init__
(
self
,
horz_fft_width
=
False
,
verbose
=
False
):
def
__init__
(
self
,
horz_fft_width
=
False
,
verbose
=
False
,
data_type
=
np
.
float32
):
"""
Alignment basic functions.
...
...
@@ -62,15 +62,16 @@ class AlignmentBase(object):
verbose: boolean, optional
When True it will produce verbose output, including plots.
"""
self
.
_init_parameters
(
horz_fft_width
,
verbose
)
self
.
_init_parameters
(
horz_fft_width
,
verbose
,
data_type
)
def
_init_parameters
(
self
,
horz_fft_width
,
verbose
):
def
_init_parameters
(
self
,
horz_fft_width
,
verbose
,
data_type
):
self
.
truncate_horz_pow2
=
horz_fft_width
if
verbose
and
not
__have_matplotlib__
:
logging
.
getLogger
(
__name__
).
warning
(
"Matplotlib not available. Plotting disabled, despite being activated by user"
)
verbose
=
False
self
.
verbose
=
verbose
self
.
data_type
=
data_type
@
staticmethod
def
refine_max_position_2d
(
f_vals
:
np
.
ndarray
,
fy
=
None
,
fx
=
None
):
...
...
@@ -319,7 +320,7 @@ class AlignmentBase(object):
@
staticmethod
def
_prepare_image
(
img
,
invalid_val
=
1e-5
,
roi_yxhw
=
None
,
median_filt_shape
=
None
,
low_pass
=
None
,
high_pass
=
None
,
img
,
invalid_val
=
1e-5
,
roi_yxhw
=
None
,
median_filt_shape
=
None
,
low_pass
=
None
,
high_pass
=
None
,
data_type
=
None
):
"""
Prepare and returns a cropped and filtered image, or array of filtered images if the input is an array of images.
...
...
@@ -343,7 +344,7 @@ class AlignmentBase(object):
The computed filter
"""
img
=
np
.
squeeze
(
img
)
# Removes singleton dimensions, but does a shallow copy
img
=
np
.
ascontiguousarray
(
img
)
img
=
np
.
ascontiguousarray
(
img
,
dtype
=
data_type
)
if
roi_yxhw
is
not
None
:
img
=
img
[
...
...
@@ -533,8 +534,8 @@ class CenterOfRotation(AlignmentBase):
img_shape
=
img_2
.
shape
roi_yxhw
=
self
.
_determine_roi
(
img_shape
,
roi_yxhw
)
img_1
=
self
.
_prepare_image
(
img_1
,
roi_yxhw
=
roi_yxhw
,
median_filt_shape
=
median_filt_shape
)
img_2
=
self
.
_prepare_image
(
img_2
,
roi_yxhw
=
roi_yxhw
,
median_filt_shape
=
median_filt_shape
)
img_1
=
self
.
_prepare_image
(
img_1
,
roi_yxhw
=
roi_yxhw
,
median_filt_shape
=
median_filt_shape
,
data_type
=
self
.
data_type
)
img_2
=
self
.
_prepare_image
(
img_2
,
roi_yxhw
=
roi_yxhw
,
median_filt_shape
=
median_filt_shape
,
data_type
=
self
.
data_type
)
cc
=
self
.
_compute_correlation_fft
(
img_1
,
img_2
,
padding_mode
,
high_pass
=
high_pass
,
low_pass
=
low_pass
)
...
...
@@ -680,7 +681,9 @@ class DetectorTranslationAlongBeam(AlignmentBase):
img_shape
=
img_stack
.
shape
[
-
2
:]
roi_yxhw
=
self
.
_determine_roi
(
img_shape
,
roi_yxhw
)
img_stack
=
self
.
_prepare_image
(
img_stack
,
roi_yxhw
=
roi_yxhw
,
median_filt_shape
=
median_filt_shape
)
img_stack
=
self
.
_prepare_image
(
img_stack
,
roi_yxhw
=
roi_yxhw
,
median_filt_shape
=
median_filt_shape
,
data_type
=
self
.
data_type
)
# do correlations
ccs
=
[
...
...
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