27 #ifndef improc_sourceFinder_hpp
28 #define improc_sourceFinder_hpp
33 #include "../math/vectorUtils.hpp"
44 template<
typename _realT>
62 std::vector<float> m_vals;
63 std::vector<pixelT> m_pixs;
64 std::vector<size_t> m_snr;
80 void treshold(
const realT & thresh );
88 void minsep(
const realT & msep );
112 template<
typename realT>
117 template<
typename realT>
120 ) : m_threshold(thresh), m_minsep(minsep)
124 template<
typename realT>
127 m_threshold = thresh;
130 template<
typename realT>
138 template<
typename realT>
144 template<
typename realT>
150 template<
typename realT>
156 template<
typename realT>
159 m_useMedian = useMed;
162 template<
typename realT>
168 template<
typename realT>
171 m_vals.resize(im.rows()*im.cols());
172 m_pixs.resize(im.rows()*im.cols());
175 for(
int cc=0;cc<im.cols();++cc)
177 for(
int rr=0;rr<im.rows();++rr)
179 m_vals[p] = im(rr,cc);
193 for(
size_t n=0; n < m_vals.size(); ++n)
195 if( (m_vals[n]-mm) / std >= m_threshold )
202 realT mms2 = m_minsep*m_minsep;
203 for(
long n =0; n < m_snr.size(); ++n)
205 for(
long m=0; m < m_snr.size(); ++m)
210 realT d2 = pow( m_pixs[m_snr[n]].first - m_pixs[m_snr[m]].first,2) + pow( m_pixs[m_snr[n]].second - m_pixs[m_snr[m]].second,2);
214 if( m_vals[m_snr[n]] < m_vals[m_snr[m]] )
216 m_snr.erase(m_snr.begin() + n);
222 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]];
Find stars in an image by SNR thresholding.
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 clear()
Clear the working memory.
std::pair< int, int > pixelT
Pixel coordinates.
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.