27#ifndef improc_aperturePhotometer_hpp
28#define improc_aperturePhotometer_hpp
55template <
typename realT>
72 bool m_useNanMask{
false };
79 std::vector<realT> m_bgx;
80 std::vector<realT> m_bgy;
152 std::vector<realT> *deltaPhot,
165 void bgMin( realT bgm )
170 void bgMax( realT bgx )
175 void bg( realT bgm, realT bgx )
182template <
typename realT>
201 std::map<realT, size_t> unrads;
204 for(
int i = 0; i < radIm.cols(); ++i )
206 for(
int j = 0; j < radIm.rows(); ++j )
209 unrads.insert( std::pair<realT, size_t>( radIm( j, i ), 0 ) );
215 typename std::map<realT, size_t>::iterator it;
217 for( it = unrads.begin(); it != unrads.end(); ++it )
224 for(
int i = 0; i < radIm.cols(); ++i )
226 for(
int j = 0; j < radIm.rows(); ++j )
228 it = unrads.find( radIm( j, i ) );
233 if( m_bgMax > m_bgMin && m_bgMin > 0 )
238 for(
int cc = 0; cc < radIm.cols(); ++cc )
240 for(
int rr = 0; rr < radIm.rows(); ++rr )
242 if( radIm( rr, cc ) >= m_bgMin && radIm( rr, cc ) <= m_bgMax )
244 m_bgx.push_back( rr );
245 m_bgy.push_back( cc );
254template <
typename realT>
257 realT xcen = 0.5 * ( 1.0 * sizeX - 1.0 );
258 realT ycen = 0.5 * ( 1.0 * sizeY - 1.0 );
260 return resize( sizeX, sizeY, xcen, ycen );
263template <
typename realT>
269template <
typename realT>
271 std::vector<realT> &deltaPhot,
278template <
typename realT>
280 std::vector<realT> *deltaPhot,
293 int x0 = xcen - maxr;
296 int x1 = xcen + maxr;
300 int y0 = ycen - maxr;
303 int y1 = ycen + maxr;
309 if( m_bgx.size() > 0 )
311 std::vector<realT> bgann( m_bgx.size() );
312 for(
size_t n = 0; n < m_bgx.size(); ++n )
314 bgann[n] = im( (
int)m_bgx[n], (
int)m_bgy[n] );
318 std::cerr <<
"background: " << bg <<
"\n";
325 for(
int i = y0; i <= y1; ++i )
327 for(
int j = x0; j <= x1; ++j )
335 for(
int i = y0; i <= y1; ++i )
337 for(
int j = x0; j <= x1; ++j )
346 if( deltaPhot !=
nullptr )
352 for(
int i = 1; i <
cumPhot.size(); ++i )
Class for performing aperture photometry on images.
eigenImage< size_t > m_indexIm
Maps a pixel in the image to the position in the radius vector.
realT radius(size_t i)
Get the radius value at an index of the vector.
int resize(int sizeX, int sizeY, realT xcen, realT ycen)
Resize the photometer, recalculating the radius vector and index image.
int cumPhot(std::vector< realT > &cumPhot, eigenImage< realT > &im, realT maxr=0)
Get the cumulative photometry of an image as a function of radius.
std::vector< realT > m_radius
Holds the ordered unique radii of the pixels in the image.
int cumPhotWork(std::vector< realT > &cumPhot, std::vector< realT > *deltaPhot, eigenImage< realT > &im, realT maxr=0)
Get the cumulative photometry of an image as a function of radius.
int m_sizeY
The size of the image in Y (columns).
int m_sizeX
The size of the image in X (rows).
Tools for using the eigen library for image processing.
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
void radiusImage(eigenT &m, typename eigenT::Scalar xc, typename eigenT::Scalar yc, typename eigenT::Scalar scale=1)
Fills in the cells of an Eigen 2D Array with their radius from the center.
vectorT::value_type vectorMedian(const vectorT &vec, vectorT *work=0)
Calculate median of a vector, leaving the vector unaltered.
Declares and defines functions to work with image masks.