Xmipp  v3.23.11-Nereus
iterative_alignment_estimator.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: David Strelak (davidstrelak@gmail.com)
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #ifndef LIBRARIES_RECONSTRUCTION_ITERATIVE_ALIGNMENT_ESTIMATOR_H_
27 #define LIBRARIES_RECONSTRUCTION_ITERATIVE_ALIGNMENT_ESTIMATOR_H_
28 
29 #include "arotation_estimator.h"
30 #include "ashift_estimator.h"
31 #include "align_type.h"
33 #include "core/transformations.h"
34 #include "data/filters.h"
36 #include "CTPL/ctpl_stl.h"
38 #include "amerit_computer.h"
39 
43 namespace Alignment {
44 
45 template<typename T>
47 public:
49  AShiftEstimator<T> &shift_estimator,
50  BSplineGeoTransformer<T> &interpolator,
51  AMeritComputer<T> &meritComputer,
52  ctpl::thread_pool &threadPool) :
53  m_rot_est(rot_estimator),
54  m_shift_est(shift_estimator),
55  m_meritComputer(meritComputer),
56  m_threadPool(threadPool),
57  m_transformer(interpolator) {
58  m_sameEstimators = ((void*)&m_shift_est == (void*)&m_rot_est);
59  this->check();
60  }
61 
62  void loadReference(const T *ref);
63 
64  AlignmentEstimation compute(const T *others, // it would be good if data is normalized, but probably it does not have to be
65  unsigned iters = 3);
66 protected:
67  static void sApplyTransform(ctpl::thread_pool &pool, const Dimensions &dims, // FIXME DS remove, also includes
68  const AlignmentEstimation &estimation,
69  const T *orig, T *copy, bool hasSingleOrig);
70 
71 private:
72  ARotationEstimator<T> &m_rot_est;
73  AShiftEstimator<T> &m_shift_est;
74  BSplineGeoTransformer<T> &m_transformer;
75  AMeritComputer<T> &m_meritComputer;
76  ctpl::thread_pool &m_threadPool;
77  bool m_sameEstimators;
78 
79  T *applyTransform(const AlignmentEstimation &estimation);
80 
81  template<typename U, typename F>
82  void updateEstimation(AlignmentEstimation &est,
83  const U &newVals, const F &func);
84 
85  void compute(unsigned iters, AlignmentEstimation &est,
86  bool rotationFirst);
87 
88  void check();
89 
90  void print(const AlignmentEstimation &e);
91 };
92 
93 
94 } /* namespace Alignment */
96 #endif /* LIBRARIES_RECONSTRUCTION_ITERATIVE_ALIGNMENT_ESTIMATOR_H_ */
static void sApplyTransform(ctpl::thread_pool &pool, const Dimensions &dims, const AlignmentEstimation &estimation, const T *orig, T *copy, bool hasSingleOrig)
AlignmentEstimation compute(const T *others, unsigned iters=3)
IterativeAlignmentEstimator(ARotationEstimator< T > &rot_estimator, AShiftEstimator< T > &shift_estimator, BSplineGeoTransformer< T > &interpolator, AMeritComputer< T > &meritComputer, ctpl::thread_pool &threadPool)