27#ifndef improc_sourceFinder_hpp
28#define improc_sourceFinder_hpp
43template <
typename _realT>
61 std::vector<float> m_vals;
62 std::vector<pixelT> m_pixs;
63 std::vector<size_t> m_snr;
78 void treshold(
const realT &thresh );
86 void minsep(
const realT &msep );
109template <
typename realT>
114template <
typename realT>
119template <
typename realT>
125template <
typename realT>
133template <
typename realT>
139template <
typename realT>
145template <
typename realT>
151template <
typename realT>
157template <
typename realT>
163template <
typename realT>
166 m_vals.resize( im.rows() * im.cols() );
167 m_pixs.resize( im.rows() * im.cols() );
170 for(
int cc = 0; cc < im.cols(); ++cc )
172 for(
int rr = 0; rr < im.rows(); ++rr )
174 m_vals[p] = im( rr, cc );
175 m_pixs[p] = { rr, cc };
190 for(
size_t n = 0; n < m_vals.size(); ++n )
194 m_snr.push_back( n );
200 for(
long n = 0; n < m_snr.size(); ++n )
202 for(
long m = 0; m < m_snr.size(); ++m )
208 realT d2 = pow( m_pixs[m_snr[n]].first - m_pixs[m_snr[m]].first, 2 ) +
209 pow( m_pixs[m_snr[n]].second - m_pixs[m_snr[m]].second, 2 );
213 if( m_vals[m_snr[n]] < m_vals[m_snr[m]] )
215 m_snr.erase( m_snr.begin() + n );
221 m_snr.erase( m_snr.begin() + m );
231 std::vector<pixelT> found( m_snr.size() );
233 for(
size_t n = 0; n < m_snr.size(); ++n )
235 found[n] = m_pixs[m_snr[n]];
std::pair< int, int > pixelT
Pixel coordinates.
realT minsep()
Get the minimum separation between stars.
realT m_threshold
The SNR threshold to use.
realT m_minsep
The minimum separation between stars. Closer SNR detections are treated as the same star.
bool useMedian()
Get the useMedian flag.
sourceFinder()
Default c'tor.
bool m_useMedian
If true, then the median is used for standard deviation calculation. The mean is used otherwise.
std::vector< pixelT > operator()(const eigenImage< realT > &im)
Find stars in an image.
void treshold(const realT &thresh)
Set the SNR threshold.
_realT realT
The real valued type in which to do calculations.
realT threshold()
Get the SNR threshold.
void minsep(const realT &msep)
Set the minimum separation.
void clear()
Clear the working memory.
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.
valueT vectorMean(const valueT *vec, size_t sz)
Calculate the mean of a vector.
valueT vectorVariance(const valueT *vec, size_t sz, valueT mean)
Calculate the variance of a vector relative to a supplied mean value.
vectorT::value_type vectorMedian(const vectorT &vec, vectorT *work=0)
Calculate median of a vector, leaving the vector unaltered.
Header for the std::vector utilities.