ifw-odp  2.0.0-alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
recipe.hpp
Go to the documentation of this file.
1 
9 #ifndef ODP_RECIPE_HPP
10 #define ODP_RECIPE_HPP
11 
12 
13 #ifndef __cplusplus
14 #error This is a C++ include file and cannot be used from plain C
15 #endif
16 
17 // System header files
18 #include <iostream>
19 #include <sstream>
20 #include <string>
21 #include <vector>
22 #include <algorithm>
23 
24 // Local header files
25 #include <rad/logger.hpp>
26 #include "cppcpl/image.hpp"
27 #include "cppcpl/array.hpp"
28 #include "cppcpl/matrix.hpp"
29 
30 namespace odp {
31 
32 
40  typedef struct
41  {
42  double xpos; // x position of the object
43  double xposErr; // x position error
44  double ypos; // y position of the object
45  double yposErr; // y position error
46  double fwhmX; // FWHM along the first axis
47  double fwhmXErr; // FWHM error along the first axis
48  double fwhmY; // FWHM along the second axis
49  double fwhmYErr; // FWHM error along the second axis
50  double angle; // the angle of the first axis with the horizontal in degrees
51  double angleErr; // the angle error
52  double peak; // the peak value of the object
53  double peakErr; // the peak error
54  double bckgrd; // the background computed
55  double bckgrdErr;// the background error
56  } Iqe;
57 
65  struct CenterGauss
66  {
68  std::string Center() {
69  std::ostringstream strs;
70  strs << center[0] << " " << center[1];
71  return strs.str();
72  }
73 
74  std::array<double, 2> center;
75  std::array<double, 2> center_err;
76  std::array<double, 2> fwhm;
77  std::array<double, 2> fwhm_err;
78  std::array<double, 2> sigma;
79  std::array<double, 2> sigma_err;
80  double intensity; // Intensity at the center
81  };
82 
90  typedef struct
91  {
92  double center_x; // X slit center
93  double center_y; // Y slit center
94  double angle; // slit angle (tilt)
95  } SlitPos;
96 
97  typedef struct
98  {
99  double length;
100  double width;
101  } Size;
102 
110  typedef struct
111  {
114  } RectAperture;
115 
123  typedef struct
124  {
125  double center_x;
126  double center_y;
127  double radius;
128  double r_sigma;
130 
143  class Recipe : virtual public odp::Error
144  {
145  public:
151  Recipe();
152 
158  ~Recipe();
159 
160  // Recipes functions
161 
180  void GetCenterGauss(const odp::Image *image,
181  cpl_size llx,
182  cpl_size lly,
183  cpl_size urx,
184  cpl_size ury,
185  CenterGauss *cen_gauss,
186  const int robustness=0);
187 
217  void GetCenterMoment(const odp::Image *image,
218  cpl_size llx,
219  cpl_size lly,
220  cpl_size urx,
221  cpl_size ury,
222  bool wdw_enlarge,
223  double gain,
224  CenterGauss *cenMoment);
225 
256  void GetMultiCenterGauss(const odp::Image *image,
257  const odp::Matrix *ref,
258  unsigned int areasize,
259  odp::Matrix *center,
260  odp::Matrix *center_err,
261  odp::Matrix *sigma,
262  odp::Matrix *sigma_err,
263  odp::Matrix *fwhm,
264  odp::Matrix *fwhm_err,
265  odp::Matrix *intensities,
266  odp::Array *err_codes,
267  const int robustness);
268 
286  void GetIqe(const odp::Image *image,
287  const cpl_size startX,
288  const cpl_size startY,
289  const cpl_size endX,
290  const cpl_size endY,
291  Iqe *iqe) ;
292 
307  void GetSlitPos(const odp::Image *image,
308  const int max_width,
309  SlitPos *slit);
310 
332  void AlignPoints(const odp::Matrix *matrix1,
333  const odp::Matrix *matrix2,
334  unsigned int mode,
335  odp::Matrix *trans,
336  odp::Matrix *shift,
337  odp::Matrix *rot);
338 
366  void AlignCorrelate(const odp::Image *img1,
367  const odp::Image *img2,
368  const odp::Matrix *ref,
369  unsigned int wsize,
370  double maxd,
371  unsigned int mode,
372  odp::Matrix *trans,
373  odp::Matrix *shift,
374  odp::Matrix *pixels,
375  odp::Matrix *locs,
376  odp::Matrix *uncer,
377  odp::Array *err_codes);
378 
398  std::vector<double> GetRngPoisson2d(int llx,
399  int lly,
400  int urx,
401  int ury,
402  int homogenity,
403  int npairs);
404 
405 
425  void GetRngPoisson2d(double llx,
426  double lly,
427  double urx,
428  double ury,
429  int homogenity,
430  int npairs,
431  void **buffer_ptr,
432  cpl_type cpltype=CPL_TYPE_DOUBLE);
433 
452  void GetRectangularAperture(const odp::Image *image,
453  const cpl_size llx,
454  const cpl_size lly,
455  const cpl_size urx,
456  const cpl_size ury,
457  RectAperture *aperture,
458  odp::Matrix *stat);
459 
478  void GetCircularAperture(const odp::Image *image,
479  const cpl_size llx,
480  const cpl_size lly,
481  const cpl_size urx,
482  const cpl_size ury,
483  CircularAperture *aperture,
484  odp::Matrix *stat);
485 
504  void EstimateBackground(const odp::Image *img,
505  const cpl_size llx,
506  const cpl_size lly,
507  const cpl_size urx,
508  const cpl_size ury,
509  double *sigma,
510  cpl_size *nused,
511  double *background);
512 
525  void EstimateFwhm(const odp::Image *img,
526  double peak_pos1,
527  double peak_pos2,
528  double bckg_level,
529  double *fwhm);
530 
551  void GetBarycentre(const odp::Image *img,
552  const cpl_size llx,
553  const cpl_size lly,
554  const cpl_size urx,
555  const cpl_size ury,
556  double bckg_level,
557  double cut_level,
558  double centre[2],
559  double *weight,
560  cpl_size *nused);
561 
578  void DetectCircularApertures(const odp::Image *img,
579  const cpl_size llx,
580  const cpl_size lly,
581  const cpl_size urx,
582  const cpl_size ury,
583  odp::Matrix *stat);
584 
585 
586  private:
587  static bool m_random_seed;
588 
589  };
590 
591 }
592 #endif
double intensity
Definition: recipe.hpp:80
double length
Definition: recipe.hpp:99
double angle
Definition: recipe.hpp:94
This class is C++ wrapper for a CPL image object. It provides a simplified interface that allows to c...
Definition: image.hpp:43
double width
Definition: recipe.hpp:100
void GetRectangularAperture(const odp::Image *image, const cpl_size llx, const cpl_size lly, const cpl_size urx, const cpl_size ury, RectAperture *aperture, odp::Matrix *stat)
Wrapper to the CLIPM rectangular characterization.
Definition: recipe.cpp:439
double fwhmYErr
Definition: recipe.hpp:49
This class is C++ wrapper for a CPL and CLIPM recipes. It provides a simplified interface that allows...
Definition: recipe.hpp:143
void AlignPoints(const odp::Matrix *matrix1, const odp::Matrix *matrix2, unsigned int mode, odp::Matrix *trans, odp::Matrix *shift, odp::Matrix *rot)
Linear transformation between two set of points.
Definition: recipe.cpp:260
Matrix class header file.
void GetIqe(const odp::Image *image, const cpl_size startX, const cpl_size startY, const cpl_size endX, const cpl_size endY, Iqe *iqe)
Compute image quality estimator over an image subwindow.
Definition: recipe.cpp:191
void GetMultiCenterGauss(const odp::Image *image, const odp::Matrix *ref, unsigned int areasize, odp::Matrix *center, odp::Matrix *center_err, odp::Matrix *sigma, odp::Matrix *sigma_err, odp::Matrix *fwhm, odp::Matrix *fwhm_err, odp::Matrix *intensities, odp::Array *err_codes, const int robustness)
Compute multiple center gauss of an image.
Definition: recipe.cpp:106
double r_sigma
Definition: recipe.hpp:128
double xpos
Definition: recipe.hpp:42
double center_x
Definition: recipe.hpp:92
void EstimateFwhm(const odp::Image *img, double peak_pos1, double peak_pos2, double bckg_level, double *fwhm)
Estimate the FWHM of a round object.
Definition: recipe.cpp:550
Recipe()
Class constructor.
Definition: recipe.cpp:17
double peakErr
Definition: recipe.hpp:53
void DetectCircularApertures(const odp::Image *img, const cpl_size llx, const cpl_size lly, const cpl_size urx, const cpl_size ury, odp::Matrix *stat)
Wrapper to the CLIPM detect circular aperture.
Definition: recipe.cpp:608
void GetCenterGauss(const odp::Image *image, cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury, CenterGauss *cen_gauss, const int robustness=0)
Compute the center gauss of an image subwindow.
Definition: recipe.cpp:28
void GetCenterMoment(const odp::Image *image, cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury, bool wdw_enlarge, double gain, CenterGauss *cenMoment)
Compute the center moment of an image subwindow.
Definition: recipe.cpp:66
double bckgrdErr
Definition: recipe.hpp:55
Definition: recipe.hpp:40
Size size
Definition: recipe.hpp:113
std::array< double, 2 > center
Definition: recipe.hpp:74
double bckgrd
Definition: recipe.hpp:54
This class is C++ wrapper for a CPL matrix object. It provides a simplified interface that allows to ...
Definition: matrix.hpp:38
double center_x
Definition: recipe.hpp:125
Definition: recipe.hpp:123
This class handle the errors produced by the calling of image processing routines.
Definition: error.hpp:34
double angleErr
Definition: recipe.hpp:51
double xposErr
Definition: recipe.hpp:43
std::vector< double > GetRngPoisson2d(int llx, int lly, int urx, int ury, int homogenity, int npairs)
Generates a set of random numbers within a box.
Definition: recipe.cpp:378
std::array< double, 2 > sigma
Definition: recipe.hpp:78
std::string Center()
Definition: recipe.hpp:68
void GetSlitPos(const odp::Image *image, const int max_width, SlitPos *slit)
Computes the slit data.
Definition: recipe.cpp:236
~Recipe()
Class destructor.
Definition: recipe.cpp:23
Array class header file.
double center_y
Definition: recipe.hpp:126
double fwhmXErr
Definition: recipe.hpp:47
void EstimateBackground(const odp::Image *img, const cpl_size llx, const cpl_size lly, const cpl_size urx, const cpl_size ury, double *sigma, cpl_size *nused, double *background)
Estimate the background in an image region.
Definition: recipe.cpp:516
This class is C++ wrapper for a CPL array object. It provides a simplified interface to the INS softw...
Definition: array.hpp:39
Definition: recipe.hpp:97
void GetBarycentre(const odp::Image *img, const cpl_size llx, const cpl_size lly, const cpl_size urx, const cpl_size ury, double bckg_level, double cut_level, double centre[2], double *weight, cpl_size *nused)
Compute the barycentre of an object.
Definition: recipe.cpp:573
CenterGauss()
Definition: recipe.hpp:67
SlitPos position
Definition: recipe.hpp:112
double yposErr
Definition: recipe.hpp:45
std::array< double, 2 > fwhm_err
Definition: recipe.hpp:77
void GetCircularAperture(const odp::Image *image, const cpl_size llx, const cpl_size lly, const cpl_size urx, const cpl_size ury, CircularAperture *aperture, odp::Matrix *stat)
Wrapper to the CLIPM circular characterization.
Definition: recipe.cpp:478
double center_y
Definition: recipe.hpp:93
Definition: recipe.hpp:65
double angle
Definition: recipe.hpp:50
double radius
Definition: recipe.hpp:127
std::array< double, 2 > fwhm
Definition: recipe.hpp:76
double fwhmY
Definition: recipe.hpp:48
std::array< double, 2 > sigma_err
Definition: recipe.hpp:79
double ypos
Definition: recipe.hpp:44
Definition: recipe.hpp:110
void AlignCorrelate(const odp::Image *img1, const odp::Image *img2, const odp::Matrix *ref, unsigned int wsize, double maxd, unsigned int mode, odp::Matrix *trans, odp::Matrix *shift, odp::Matrix *pixels, odp::Matrix *locs, odp::Matrix *uncer, odp::Array *err_codes)
Crosscorrelation of two images.
Definition: recipe.cpp:306
Definition: recipe.hpp:90
double peak
Definition: recipe.hpp:52
Image class header file.
double fwhmX
Definition: recipe.hpp:46
std::array< double, 2 > center_err
Definition: recipe.hpp:75