27 #ifndef __imCenterRadon_hpp__
28 #define __imCenterRadon_hpp__
30 #include "../math/vectorUtils.hpp"
31 #include "../math/fit/fitGaussian.hpp"
51 template<
typename transformT>
55 typedef typename transformT::arithT realT;
94 const int lbuff = transformT::lbuff;
95 const int width = transformT::width;
103 realT startX, startY;
107 for(
int i =0; i<N; ++i)
110 for(
int j=0; j<N;++j)
117 int Nang = 360./dang + 1;
120 #ifdef MX_IMPROC_IMCENTERRADON_OMP
121 #pragma omp parallel for
123 for(
int iang =0; iang < Nang; ++iang)
125 realT ang = iang*dang;
128 kern.resize(width,width);
130 realT cosang = cos(ang*3.14159/180.);
131 realT sinang = sin(ang*3.14159/180.);
135 realT xx = startX + rad * cosang;
136 realT yy = startY + rad * sinang;
144 lineint += (im.block(i0-lbuff,j0-lbuff, width, width) * kern).sum();
175 realT
mx, mn, gx, gy;
177 mx = grid.maxCoeff(&gx, &gy);
178 mn = grid.minCoeff();
184 m_fit.setArray(grid.data(), grid.rows(), grid.cols());
202 template<
typename iosT,
char comment='#'>
205 char c[] = {comment,
'\0'};
207 ios <<
c <<
"--------------------------------------\n";
208 ios <<
c <<
"mx::improc::imCenterRadon Results \n";
209 ios <<
c <<
"--------------------------------------\n";
212 ios <<
c <<
"Cost half-width: " << 0.5*math::func::sigma2fwhm<realT>( sqrt( pow(
m_fit.sigma_x(),2) + pow(
m_fit.sigma_y(),2)) *
m_dPix) <<
" pixels\n";
213 ios <<
c <<
"--------------------------------------\n";
214 ios <<
c <<
"Setup:\n";
215 ios <<
c <<
"--------------------------------------\n";
216 ios <<
c <<
"maxPix: " <<
m_maxPix <<
"\n";
217 ios <<
c <<
"dPix: " <<
m_dPix <<
"\n";
218 ios <<
c <<
"minRad: " <<
m_minRad <<
"\n";
219 ios <<
c <<
"maxRad: " <<
m_maxRad <<
"\n";
220 ios <<
c <<
"dRad: " <<
m_dRad <<
"\n";
223 ios <<
c <<
"--------------------------------------\n";
224 ios <<
c <<
"Fit results:\n" ;
225 m_fit.dumpReport(ios);
226 ios <<
c <<
"--------------------------------------\n";
236 template<
char comment ='#'>
239 return dumpResults<std::ostream, comment>(std::cout);
Class to manage fitting a 2D Gaussian to data via the levmarInterface.
Tools for using the eigen library for image processing.
constexpr units::realT c()
The speed of light.
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
realT rtod(realT q)
Convert from radians to degrees.
Image filters (smoothing, radial profiles, etc.)
A class to find the location of a peak using interpolation.
Find the center of the image of a point source using circular symmetry of the PSF.
int center(realT &x, realT &y, eigenImage< realT > &im, realT x0, realT y0)
Peform the grid search and fit.
std::ostream & dumpResults()
Output the results to std::cout.
iosT & dumpResults(iosT &ios)
Output the results to a stream.
realT m_x0
Internal storage of the guess center position.
realT m_peakTol
The tolerance for the peak finding. This is multiplicative with m_dPix.
int fitGrid(realT &x, realT &y, eigenImage< realT > grid)
Fit the transform grid.
realT m_dRad
The spacing of the radii. Default: 0.1.
realT m_maxRad
The maximum radius to include in the transform. Default: 10.0.
realT m_guessWidth
Guess in original pixels for the FWHM of the cost grid. Default is 0.5, which seems to work well in m...
realT m_dPix
The spacing of the points in the grid search. Default: 0.1.
mx::math::fit::fitGaussian2Dgen< realT > m_fit
The fitter for finding the centroid of the grid. You can use this to inspect the details of the fit i...
realT m_minRad
The minimum radius to include in the transform. Default: 1.0.
realT m_angTolPix
The angle tolerance in pixels at the maximum radius, sets the angular step size. Default is 1....
realT m_maxPix
The maximum range of the grid search, the grid will be +/- maxPix. Default: 5.0.
eigenImage< realT > m_grid
The cost grid.
realT m_y0
Internal storage of the guess center position.
Find the peak of an image using interpolation.