IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
align2D.h
Go to the documentation of this file.
1 /*!
2  * \file IMP/em2d/align2D.h
3  * \brief Alignment of images in 2D
4  * Copyright 2007-2018 IMP Inventors. All rights reserved.
5 */
6 
7 #ifndef IMPEM2D_ALIGN_2D_H
8 #define IMPEM2D_ALIGN_2D_H
9 
10 #include "IMP/em2d/em2d_config.h"
12 #include "IMP/algebra/utility.h"
14 #include "IMP/algebra/Vector2D.h"
15 #include <algorithm>
16 #include <vector>
17 
18 IMPEM2D_BEGIN_NAMESPACE
19 
20 //! Definition of the result of an alignment. Contains the transformation
21 //! to apply to the matrix to align and the cross correlation of the solution
22 typedef std::pair<algebra::Transformation2D, double> ResultAlign2D;
23 
24 //! Aligns completely two matrices (rotationally and translationally).
25 //! Uses the autocorrelation function to speed up the rotational alignment
26 /*!
27  \param[in] input Reference matrix
28  \param[in] m_to_align Matrix to align to the reference
29  \param[in] apply if true, apply the transformation
30  to m_to_align after alignment
31  \return The result. Check the definition of ResultAlign2D
32 */
33 IMPEM2DEXPORT ResultAlign2D get_complete_alignment(const cv::Mat &input,
34  cv::Mat &m_to_align,
35  bool apply = false);
36 
37 //! Aligns two matrices rotationally. Based on the autocorrelation function
38 //! of the matrices.
39 /*!
40  \param[in] input Reference matrix
41  \param[in] m_to_align Matrix to align to the reference
42  \param[in] apply if true, apply the transformation
43  to m_to_align after alignment
44  \return The result. Check the definition of ResultAlign2D
45 */
46 IMPEM2DEXPORT em2d::ResultAlign2D get_rotational_alignment(const cv::Mat &input,
47  cv::Mat &m_to_align,
48  bool apply = false);
49 
50 //! Aligns two matrices translationally
51 /*!
52  \param[in] input Reference matrix
53  \param[in] m_to_align Matrix to align to the reference
54  \param[in] apply if true, apply the transformation
55  to m_to_align after alignment
56  \return The result. Check the definition of ResultAlign2D
57 */
58 IMPEM2DEXPORT ResultAlign2D get_translational_alignment(const cv::Mat &input,
59  cv::Mat &m_to_align,
60  bool apply = false);
61 
62 //! Aligns two matrices rotationally and translationally without
63 //! performing preprocessing. Preprocessed data must be provided.
64 /*!
65  \param[in] input first matrix
66  \param[in] INPUT fft of the first matrix
67  \param[in] POLAR1 fft of the autocorrelation (in polars) of the input.
68  \param[in] m_to_align the matrix to align with the input
69  \param[in] POLAR2 fft of the autocorrelation (in polars) of m_to_align
70  \param[in] apply true if m_to_align is transformed at the end
71  \return The result. Check the definition of ResultAlign2D
72 */
74  const cv::Mat &input, const cv::Mat &INPUT, const cv::Mat &POLAR1,
75  cv::Mat &m_to_align, const cv::Mat &POLAR2, bool apply = false);
76 
77 //! Computes the rotational alignment for two autocorrelation matrices
78 //! It is assumed that the arguments are FFTs
79 /*!
80  \param[in] POLAR1 fft of the first autocorrelation (in polars)
81  \param[in] POLAR2 fft of the second autocorrelation (in polars)
82  \return The result. Check the definition of ResultAlign2D
83 */
84 IMPEM2DEXPORT ResultAlign2D
85  get_rotational_alignment_no_preprocessing(const cv::Mat &POLAR1,
86  const cv::Mat &POLAR2);
87 
88 //! Aligns two matrices translationally without preprocessing. The preprocessed
89 //! data must be provided.
90 /*!
91  \param[in] M1 the dft the first matrix (input)
92  \param[in] M2 the dft of the matrix to align with the input
93  \return The result. Check the definition of ResultAlign2D
94 */
95 IMPEM2DEXPORT ResultAlign2D
97  const cv::Mat &M2);
98 
99 //! Aligns two matrices (rotation and translation) using centers and
100 //! no preprocessing. Preprocessed data must be provided.
101 /*!
102  \param[in] center1 weighted centroid of the reference matrix
103  \param[in] center2 weighted centroid of the matrix to align
104  \param[in] AUTOC_POLAR1 fft of the autocorrelation (in polars) of the input.
105  \param[in] AUTOC_POLAR2 fft of the autocorrelation (in polars) of m_to_align
106  \return The result. Check the definition of ResultAlign2D
107 */
108 IMPEM2DEXPORT ResultAlign2D
110  const algebra::Vector2D &center1, const algebra::Vector2D &center2,
111  const cv::Mat &AUTOC_POLAR1, const cv::Mat &AUTOC_POLAR2);
112 
113 IMPEM2D_END_NAMESPACE
114 
115 #endif /* IMPEM2D_ALIGN_2D_H */
VectorD< 2 > Vector2D
Definition: VectorD.h:391
ResultAlign2D get_complete_alignment_with_centers_no_preprocessing(const algebra::Vector2D &center1, const algebra::Vector2D &center2, const cv::Mat &AUTOC_POLAR1, const cv::Mat &AUTOC_POLAR2)
ResultAlign2D get_translational_alignment(const cv::Mat &input, cv::Mat &m_to_align, bool apply=false)
Aligns two matrices translationally.
ResultAlign2D get_complete_alignment(const cv::Mat &input, cv::Mat &m_to_align, bool apply=false)
em2d::ResultAlign2D get_rotational_alignment(const cv::Mat &input, cv::Mat &m_to_align, bool apply=false)
Simple 2D vector class.
2D transformations. Copyright 2007-2018 IMP Inventors. All rights reserved.
ResultAlign2D get_rotational_alignment_no_preprocessing(const cv::Mat &POLAR1, const cv::Mat &POLAR2)
Functions to deal with very common math operations.
Functions related with rotations in em2d Copyright 2007-2018 IMP Inventors. All rights reserved...
ResultAlign2D get_translational_alignment_no_preprocessing(const cv::Mat &M1, const cv::Mat &M2)
std::pair< algebra::Transformation2D, double > ResultAlign2D
Definition: align2D.h:22
em2d::ResultAlign2D get_complete_alignment_no_preprocessing(const cv::Mat &input, const cv::Mat &INPUT, const cv::Mat &POLAR1, cv::Mat &m_to_align, const cv::Mat &POLAR2, bool apply=false)