ifw-odp  4.0.0-pre1
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 "cppcpl/image.hpp"
26 #include "cppcpl/array.hpp"
27 #include "cppcpl/matrix.hpp"
28 
29 namespace odp {
30 
31 
39  typedef struct
40  {
41  double xpos; // x position of the object
42  double xposErr; // x position error
43  double ypos; // y position of the object
44  double yposErr; // y position error
45  double fwhmX; // FWHM along the first axis
46  double fwhmXErr; // FWHM error along the first axis
47  double fwhmY; // FWHM along the second axis
48  double fwhmYErr; // FWHM error along the second axis
49  double angle; // the angle of the first axis with the horizontal in degrees
50  double angleErr; // the angle error
51  double peak; // the peak value of the object
52  double peakErr; // the peak error
53  double bckgrd; // the background computed
54  double bckgrdErr;// the background error
55  } Iqe;
56 
64  struct CenterGauss
65  {
67  std::string Center() {
68  std::ostringstream strs;
69  strs << center[0] << " " << center[1];
70  return strs.str();
71  }
72 
73  std::array<double, 2> center;
74  std::array<double, 2> center_err;
75  std::array<double, 2> fwhm;
76  std::array<double, 2> fwhm_err;
77  std::array<double, 2> sigma;
78  std::array<double, 2> sigma_err;
79  double intensity; // Intensity at the center
80  };
81 
89  typedef struct
90  {
91  double center_x; // X slit center
92  double center_y; // Y slit center
93  double angle; // slit angle (tilt)
94  } SlitPos;
95 
96  typedef struct
97  {
98  double length;
99  double width;
100  } Size;
101 
109  typedef struct
110  {
113  } RectAperture;
114 
122  typedef struct
123  {
124  double center_x;
125  double center_y;
126  double radius;
127  double r_sigma;
129 
142  class Recipe : virtual public odp::Error
143  {
144  public:
150  Recipe();
151 
157  ~Recipe();
158 
159  // Recipes functions
160 
179  void GetCenterGauss(const odp::Image *image,
180  cpl_size llx,
181  cpl_size lly,
182  cpl_size urx,
183  cpl_size ury,
184  CenterGauss *cen_gauss,
185  const int robustness=0);
186 
216  void GetCenterMoment(const odp::Image *image,
217  cpl_size llx,
218  cpl_size lly,
219  cpl_size urx,
220  cpl_size ury,
221  bool wdw_enlarge,
222  double gain,
223  CenterGauss *cenMoment);
224 
255  void GetMultiCenterGauss(const odp::Image *image,
256  const odp::Matrix *ref,
257  unsigned int areasize,
258  odp::Matrix *center,
259  odp::Matrix *center_err,
260  odp::Matrix *sigma,
261  odp::Matrix *sigma_err,
262  odp::Matrix *fwhm,
263  odp::Matrix *fwhm_err,
264  odp::Matrix *intensities,
265  odp::Array *err_codes,
266  const int robustness);
267 
285  void GetIqe(const odp::Image *image,
286  const cpl_size startX,
287  const cpl_size startY,
288  const cpl_size endX,
289  const cpl_size endY,
290  Iqe *iqe) ;
291 
306  void GetSlitPos(const odp::Image *image,
307  const int max_width,
308  SlitPos *slit);
309 
331  void AlignPoints(const odp::Matrix *matrix1,
332  const odp::Matrix *matrix2,
333  unsigned int mode,
334  odp::Matrix *trans,
335  odp::Matrix *shift,
336  odp::Matrix *rot);
337 
365  void AlignCorrelate(const odp::Image *img1,
366  const odp::Image *img2,
367  const odp::Matrix *ref,
368  unsigned int wsize,
369  double maxd,
370  unsigned int mode,
371  odp::Matrix *trans,
372  odp::Matrix *shift,
373  odp::Matrix *pixels,
374  odp::Matrix *locs,
375  odp::Matrix *uncer,
376  odp::Array *err_codes);
377 
397  std::vector<double> GetRngPoisson2d(int llx,
398  int lly,
399  int urx,
400  int ury,
401  int homogenity,
402  int npairs);
403 
404 
424  void GetRngPoisson2d(double llx,
425  double lly,
426  double urx,
427  double ury,
428  int homogenity,
429  int npairs,
430  void **buffer_ptr,
431  cpl_type cpltype=CPL_TYPE_DOUBLE);
432 
451  void GetRectangularAperture(const odp::Image *image,
452  const cpl_size llx,
453  const cpl_size lly,
454  const cpl_size urx,
455  const cpl_size ury,
456  RectAperture *aperture,
457  odp::Matrix *stat);
458 
477  void GetCircularAperture(const odp::Image *image,
478  const cpl_size llx,
479  const cpl_size lly,
480  const cpl_size urx,
481  const cpl_size ury,
482  CircularAperture *aperture,
483  odp::Matrix *stat);
484 
503  void EstimateBackground(const odp::Image *img,
504  const cpl_size llx,
505  const cpl_size lly,
506  const cpl_size urx,
507  const cpl_size ury,
508  double *sigma,
509  cpl_size *nused,
510  double *background);
511 
524  void EstimateFwhm(const odp::Image *img,
525  double peak_pos1,
526  double peak_pos2,
527  double bckg_level,
528  double *fwhm);
529 
550  void GetBarycentre(const odp::Image *img,
551  const cpl_size llx,
552  const cpl_size lly,
553  const cpl_size urx,
554  const cpl_size ury,
555  double bckg_level,
556  double cut_level,
557  double centre[2],
558  double *weight,
559  cpl_size *nused);
560 
577  void DetectCircularApertures(const odp::Image *img,
578  const cpl_size llx,
579  const cpl_size lly,
580  const cpl_size urx,
581  const cpl_size ury,
582  odp::Matrix *stat);
583 
584 
585  private:
586  static bool m_random_seed;
587 
588  };
589 
590 }
591 #endif
Array class header file.
This class is C++ wrapper for a CPL array object. It provides a simplified interface to the INS softw...
Definition: array.hpp:40
This class handle the errors produced by the calling of image processing routines.
Definition: error.hpp:35
This class is C++ wrapper for a CPL image object. It provides a simplified interface that allows to c...
Definition: image.hpp:44
This class is C++ wrapper for a CPL matrix object. It provides a simplified interface that allows to ...
Definition: matrix.hpp:39
This class is C++ wrapper for a CPL and CLIPM recipes. It provides a simplified interface that allows...
Definition: recipe.hpp:143
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:548
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:293
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:527
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:64
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:459
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:422
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:184
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 GetSlitPos(const odp::Image *image, const int max_width, SlitPos *slit)
Computes the slit data.
Definition: recipe.cpp:227
Recipe()
Class constructor.
Definition: recipe.cpp:17
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:249
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:495
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:581
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:363
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:102
~Recipe()
Class destructor.
Definition: recipe.cpp:23
Image class header file.
Matrix class header file.
Definition: array.cpp:16
Definition: recipe.hpp:65
std::array< double, 2 > sigma_err
Definition: recipe.hpp:78
CenterGauss()
Definition: recipe.hpp:66
double intensity
Definition: recipe.hpp:79
std::array< double, 2 > center_err
Definition: recipe.hpp:74
std::string Center()
Definition: recipe.hpp:67
std::array< double, 2 > center
Definition: recipe.hpp:73
std::array< double, 2 > sigma
Definition: recipe.hpp:77
std::array< double, 2 > fwhm
Definition: recipe.hpp:75
std::array< double, 2 > fwhm_err
Definition: recipe.hpp:76
Definition: recipe.hpp:123
double center_x
Definition: recipe.hpp:124
double r_sigma
Definition: recipe.hpp:127
double radius
Definition: recipe.hpp:126
double center_y
Definition: recipe.hpp:125
Definition: recipe.hpp:40
double yposErr
Definition: recipe.hpp:44
double ypos
Definition: recipe.hpp:43
double fwhmXErr
Definition: recipe.hpp:46
double xposErr
Definition: recipe.hpp:42
double fwhmX
Definition: recipe.hpp:45
double peak
Definition: recipe.hpp:51
double bckgrd
Definition: recipe.hpp:53
double peakErr
Definition: recipe.hpp:52
double angleErr
Definition: recipe.hpp:50
double fwhmYErr
Definition: recipe.hpp:48
double fwhmY
Definition: recipe.hpp:47
double bckgrdErr
Definition: recipe.hpp:54
double xpos
Definition: recipe.hpp:41
double angle
Definition: recipe.hpp:49
Definition: recipe.hpp:110
SlitPos position
Definition: recipe.hpp:111
Size size
Definition: recipe.hpp:112
Definition: recipe.hpp:97
double length
Definition: recipe.hpp:98
double width
Definition: recipe.hpp:99
Definition: recipe.hpp:90
double angle
Definition: recipe.hpp:93
double center_x
Definition: recipe.hpp:91
double center_y
Definition: recipe.hpp:92