mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
varmapToImage.hpp
Go to the documentation of this file.
1 /** \file varmapToImage.hpp
2  * \author Jared R. Males (jaredmales@gmail.com)
3  * \brief A utility to convert a wavefront variance map to an intensity image
4  * \ingroup mxAO_files
5  *
6  */
7 
8 #ifndef varmapToImage_hpp
9 #define varmapToImage_hpp
10 
11 namespace mx
12 {
13 namespace AO
14 {
15 namespace analysis
16 {
17 
18 ///Convert a wavefront variance map to an intensity image by convolving with the PSF.
19 /**
20  * The PSF should have odd dimensions, and the peak pixel should be in the center pixel
21  * defined by [0.5*psf.rows(), 0.5*psf.cols()]. The platescale (lambda/D per pixel) of the PSF should match that of
22  * the variance map. The PSF should be normalized such that the center/peak pixel has value 1 (not so that the sum of pixels is 1).
23  *
24  * \tparam imageT is an Eigen-array-like type.
25  *
26  * \ingroup mxAOAnalytic
27  */
28 template< typename imageT >
29 void varmapToImage( imageT & im, ///< [out] is the intensity image, resized to match varmap
30  imageT & varmap, ///< [in] is the wavefront variance map
31  imageT & psf ///< [in] is the point spread function
32  )
33 {
34  typedef typename imageT::Scalar floatT;
35 
36  im.resize(varmap.rows(), varmap.cols());
37  im.setZero();
38 
39 
40  floatT psfNorm = 1.0;//psf.sum();
41 
42  int psf_i, psf_j;
43  floatT psfVal;
44 
45  #pragma omp parallel for
46  for(int i=0; i< im.rows(); ++i)
47  {
48  for(int j=0; j< im.cols(); ++j)
49  {
50  for( int ii =0; ii < im.rows(); ++ii)
51  {
52  psf_i = 0.5*(psf.rows()) - (ii - i);
53 
54  if( psf_i < 0 || psf_i >= psf.rows()) continue;
55 
56  for( int jj =0; jj < im.cols(); ++jj)
57  {
58  psf_j = 0.5*(psf.cols()) - (jj - j);
59 
60  if( psf_j >= 0 and psf_j < psf.cols() )
61  {
62  psfVal = psf(psf_i, psf_j)/psfNorm;
63  im(i, j) += varmap(ii, jj) * psfVal;
64  }
65  }
66  }
67  }
68  }
69 }
70 
71 } //namespace analysis
72 } //namespace AO
73 } //namespace mx
74 
75 #endif //varmapToImage_hpp
76 
void varmapToImage(imageT &im, imageT &varmap, imageT &psf)
Convert a wavefront variance map to an intensity image by convolving with the PSF.
The mxlib c++ namespace.
Definition: mxError.hpp:107