mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
imagePeakInterp.hpp
Go to the documentation of this file.
1 /** \file imagePeakInterp.hpp
2  * \brief A class to find the location of a peak using interpolation
3  * \ingroup image_processing_files
4  * \author Jared R. Males (jaredmales@gmail.com)
5  *
6  */
7 
8 //***********************************************************************//
9 // Copyright 2023 Jared R. Males (jaredmales@gmail.com)
10 //
11 // This file is part of mxlib.
12 //
13 // mxlib is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // mxlib is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with mxlib. If not, see <http://www.gnu.org/licenses/>.
25 //***********************************************************************//
26 
27 #ifndef __imagePeakInterp_hpp__
28 #define __imagePeakInterp_hpp__
29 
30 #include "eigenImage.hpp"
31 #include "imageTransforms.hpp"
32 
33 //#define ICCS_OMP
34 namespace mx
35 {
36 namespace improc
37 {
38 
39 
40 /// Find the peak of an image using interpolation
41 /** Interpolates onto a finer grid according to m_tol
42  *
43  * \tparam transformT is a transformation type
44  *
45  * \ingroup image_reg
46  */
47 template<typename transformT>
49 {
50 
51  typedef typename transformT::arithT realT;
52 
53  transformT m_transform;
54 
55  realT m_tol {0.1};
56 
57  eigenImage<realT> m_magIm;
58 
60  {
61  }
62 
63  imagePeakInterp( realT tol ) : m_tol(tol)
64  {
65  }
66 
67 
68  void operator()( realT & x,
69  realT & y,
71  )
72  {
73  int r = (1.0*im.rows())/m_tol + 1;
74  int c = (1.0*im.cols())/m_tol + 1;
75 
76 
77  m_magIm.resize(r, c);
78 
79  imageMagnify(m_magIm, im, m_transform);
80 
81  int nx, ny;
82  m_magIm.maxCoeff(&nx,&ny);
83 
84  x = nx*m_tol;
85  y = ny*m_tol;
86 
87 
88  }
89 
90 
91 
92 };
93 
94 } //improc
95 } //mx
96 
97 #endif //__imagePeakInterp_hpp__
Tools for using the eigen library for image processing.
constexpr units::realT c()
The speed of light.
Definition: constants.hpp:60
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
Definition: eigenImage.hpp:44
void imageMagnify(arrOutT &transim, const arrInT &im, transformT trans)
Magnify an image.
Image interpolation and transformation.
The mxlib c++ namespace.
Definition: mxError.hpp:107
Find the peak of an image using interpolation.