ifw-odp 5.0.0
Loading...
Searching...
No Matches
image.hpp
Go to the documentation of this file.
1
9#ifndef ODP_IMAGE_HPP
10#define ODP_IMAGE_HPP
11
12#ifndef __cplusplus
13#error This is a C++ include file and cannot be used from plain C
14#endif
15
16// System header files
17#include <iostream>
18
19// CPL header files
20#include "cpl_image.h"
21#include "ifw/odp/clipm/clipm.h"
22
23// Local header files
26
27
28
29
30namespace ifw::odp {
31
32
43 class Image : virtual public odp::Error
44 {
45 public:
52 Image();
53
66 explicit Image(const cpl_size size_x,
67 const cpl_size size_y,
68 const cpl_type type);
69
79 explicit Image(const Image &image);
80
89 explicit Image(const Mask &mask);
90
101 explicit Image(const Image &image, cpl_type type);
102
119 explicit Image(const Image &image,
120 const cpl_size llx,
121 const cpl_size lly,
122 const cpl_size urx,
123 const cpl_size ury);
124
141 explicit Image(const Mask &mask,
142 const cpl_size llx,
143 const cpl_size lly,
144 const cpl_size urx,
145 const cpl_size ury);
146
163 explicit Image(const Image *image,
164 const cpl_size llx,
165 const cpl_size lly,
166 const cpl_size urx,
167 const cpl_size ury);
168
187 explicit Image(const Image *image,
188 const cpl_size startx,
189 const cpl_size starty,
190 const cpl_size size_single_det_x,
191 const cpl_size size_single_det_y,
192 const cpl_size size_gap_x,
193 const cpl_size size_gap_y);
194
202 virtual ~Image();
203
211 void GetImagePtr(void **data_ptr) const;
212
219 cpl_size GetTypeSize() const;
220
227 inline void* GetImagePtr() const;
228
235 inline cpl_size GetWidth() const;
236
243 inline cpl_size GetHeight() const;
244
251 inline cpl_size GetSize() const;
252
259 inline bool IsImage() const;
260
267 inline bool Status() const;
268
275 inline cpl_type GetCplType() const;
276
283 inline cpl_image *GetCplImage() const;
284
291 void SetCplImage(cpl_image *image);
292
303 void Copy(const Image&,
304 const cpl_size pos_x,
305 const cpl_size pos_y);
306
315 void Save(const std::string filename,
316 cpl_type type=CPL_TYPE_FLOAT);
317
328 void Load(const std::string filename,
329 const cpl_size plane=0,
330 const cpl_size extension=0,
331 cpl_type type=CPL_TYPE_UNSPECIFIED);
332
348 void Load(const std::string filename,
349 const cpl_size llx,
350 const cpl_size lly,
351 const cpl_size urx,
352 const cpl_size ury,
353 const cpl_size plane=0,
354 const cpl_size extension=0,
355 cpl_type type=CPL_TYPE_UNSPECIFIED);
356
357
367 void Unload();
368
369 // Routines to get the pixel value at given position
370
379 double Get(cpl_size xpos, cpl_size ypos) const;
380
389 void Get(cpl_size xpos, cpl_size ypos, double *value);
390
399 void Set(cpl_size xpos, cpl_size ypos, double value);
400
401 // Routines to handle bad pixels
402
409 void SetBadPixelMap(const Mask &mask);
410
417 cpl_size CountBadPixelMap();
418
419 // Basic interface functions to CPL
432 void Exponential(const double base);
433
445 void Logarithm (const double base);
446
458 void Power (const double exponent);
459
471 void Absolute ();
472
488 void Normalise (cpl_norm norm=CPL_NORM_SCALE);
489
501 void Turn (int rotation=-1);
502
514 void FFT (Image *imaginary, unsigned mode=CPL_FFT_DEFAULT);
515
529 void Threshold (double lo_cut,
530 double hi_cut,
531 double assign_lo_cut,
532 double assign_hi_cut);
533
545 void Rebin(cpl_size xstart,
546 cpl_size ystart,
547 cpl_size xstep,
548 cpl_size ystep,
549 Image& new_image);
550
551 // Generation functions
563 void FillNoise(const double min_pix,
564 const double max_pix);
565
580 void FillGaussian(const double cen_x,
581 const double cen_y,
582 const double norm,
583 const double sigma_x,
584 const double sigma_y);
585
586 // Object operators
595 Image& operator+(const double);
596
605 Image& operator+(const Image&);
606
614 Image& operator-(const double);
615
623 Image& operator-(const Image&);
624
633 Image& operator/(const double);
634
642 Image& operator/(const Image&);
643
651 Image& operator*(const double);
652
660 Image& operator*(const Image&);
661
669 Image& operator+=(const double);
670
678 Image& operator+=(const Image&);
679
687 Image& operator-=(const double);
688
696 Image& operator-=(const Image&);
697
705 Image& operator/=(const double);
706
714 Image& operator/=(const Image&);
715
723 Image& operator*=(const double);
724
732 Image& operator*=(const Image&);
733
734
742 Image& operator=(const Image&);
743
750 bool operator==(const Image&) const;
751
758 bool operator!=(const Image&) const;
759
760 protected:
761 cpl_type m_cpl_type;
762 cpl_image* m_cpl_image;
763
764
765 };
766}
767
768#include "image.ipp"
769
770#endif
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
bool Status() const
Get image status.
void FillNoise(const double min_pix, const double max_pix)
It generates a CPL image with uniform random noise distribution.
Definition image.cpp:283
void SetBadPixelMap(const Mask &mask)
Set the bad pixel map.
Definition image.cpp:684
cpl_type GetCplType() const
Get CPL image type.
cpl_image * m_cpl_image
Definition image.hpp:762
void Exponential(const double base)
Computes the image exponential.
Definition image.cpp:180
void Copy(const Image &, const cpl_size pos_x, const cpl_size pos_y)
Copy input image object in the coordinates specified.
Definition image.cpp:310
Image & operator*(const double)
Overload operator*.
Definition image.cpp:455
Image & operator=(const Image &)
Overload operator=.
Definition image.cpp:558
cpl_image * GetCplImage() const
Get CPL image.
Image & operator*=(const double)
Overload operator*=.
Definition image.cpp:536
bool IsImage() const
Check is CPL image is valid.
Image & operator+(const double)
Overload operator+.
Definition image.cpp:394
void FillGaussian(const double cen_x, const double cen_y, const double norm, const double sigma_x, const double sigma_y)
It generates an image from a 2d gaussian function.
Definition image.cpp:291
void Load(const std::string filename, const cpl_size plane=0, const cpl_size extension=0, cpl_type type=CPL_TYPE_UNSPECIFIED)
Load CPL image from a FITS file.
Definition image.cpp:340
cpl_size GetWidth() const
Get image width.
void Save(const std::string filename, cpl_type type=CPL_TYPE_FLOAT)
Save CPL image into a FITS file.
Definition image.cpp:324
void Turn(int rotation=-1)
Rotate CPL image.
Definition image.cpp:223
Image & operator/(const double)
Overload operator/.
Definition image.cpp:435
void SetCplImage(cpl_image *image)
Set CPL image.
void Unload()
Release CPL image.
Definition image.cpp:303
bool operator==(const Image &) const
Overload operator==.
Definition image.cpp:582
cpl_size CountBadPixelMap()
Count the bad pixels.
Definition image.cpp:700
virtual ~Image()
Class destructor.
Definition image.cpp:137
Image(const Mask &mask, const cpl_size llx, const cpl_size lly, const cpl_size urx, const cpl_size ury)
Copy constructor.
Image & operator/=(const double)
Overload operator/=.
Definition image.cpp:515
void Absolute()
Computes the image absolute.
Definition image.cpp:207
double Get(cpl_size xpos, cpl_size ypos) const
Get the value of a pixel at a given position.
Definition image.cpp:638
void Set(cpl_size xpos, cpl_size ypos, double value)
Set the value of a pixel at a given position.
Definition image.cpp:671
void Normalise(cpl_norm norm=CPL_NORM_SCALE)
Normalize the CPL image.
Definition image.cpp:215
cpl_type m_cpl_type
Definition image.hpp:761
void Logarithm(const double base)
Computes the image logarithm.
Definition image.cpp:189
void * GetImagePtr() const
Get pointer to image data.
void Rebin(cpl_size xstart, cpl_size ystart, cpl_size xstep, cpl_size ystep, Image &new_image)
Image rebin.
Definition image.cpp:265
void Power(const double exponent)
Computes the image power.
Definition image.cpp:198
void FFT(Image *imaginary, unsigned mode=CPL_FFT_DEFAULT)
Fast Fourier Transfor of a CPL image.
Definition image.cpp:232
cpl_size GetHeight() const
Get image height.
cpl_size GetSize() const
Get image size.
Image()
Class constructor.
Definition image.cpp:23
Image & operator-(const double)
Overload operator-.
Definition image.cpp:415
Image & operator+=(const double)
Overload operator+=.
Definition image.cpp:475
bool operator!=(const Image &) const
Overload operator!=.
Definition image.cpp:610
Image & operator-=(const double)
Overload operator-=.
Definition image.cpp:495
void Threshold(double lo_cut, double hi_cut, double assign_lo_cut, double assign_hi_cut)
Threshold a CPL image to a given interval.
Definition image.cpp:253
cpl_size GetTypeSize() const
Get size of the image built-in type.
Definition image.cpp:156
This class is C++ wrapper for a CPL mask object. It provides a simplified interface that allows to ca...
Definition mask.hpp:38
Error class header file.
Mask class header file.
Definition array.cpp:16