ifw-odp 5.1.1
 
Loading...
Searching...
No Matches
image.hpp
Go to the documentation of this file.
1
7
8#ifndef ODP_IMAGE_HPP
9#define ODP_IMAGE_HPP
10
11#ifndef __cplusplus
12#error This is a C++ include file and cannot be used from plain C
13#endif
14
15// System header files
16#include <iostream>
17
18// CPL header files
19#include "cpl_image.h"
20#include "ifw/odp/clipm/clipm.h"
21
22#include <cstdint>
23
24// Local header files
27
28namespace ifw::odp {
29
40 class Image : virtual public odp::Error
41 {
42 public:
49 Image();
50
63 explicit Image(const cpl_size size_x,
64 const cpl_size size_y,
65 const cpl_type type);
66
76 explicit Image(const Image &image);
77
86 explicit Image(const Mask &mask);
87
98 explicit Image(const Image &image, cpl_type type);
99
116 explicit Image(const Image &image,
117 const cpl_size llx,
118 const cpl_size lly,
119 const cpl_size urx,
120 const cpl_size ury);
121
138 explicit Image(const Mask &mask,
139 const cpl_size llx,
140 const cpl_size lly,
141 const cpl_size urx,
142 const cpl_size ury);
143
160 explicit Image(const Image *image,
161 const cpl_size llx,
162 const cpl_size lly,
163 const cpl_size urx,
164 const cpl_size ury);
165
184 explicit Image(const Image *image,
185 const cpl_size startx,
186 const cpl_size starty,
187 const cpl_size size_single_det_x,
188 const cpl_size size_single_det_y,
189 const cpl_size size_gap_x,
190 const cpl_size size_gap_y);
191
200 explicit Image(uintptr_t image_handle);
201
209 virtual ~Image();
210
218 void GetImagePtr(void **data_ptr) const;
219
226 cpl_size GetTypeSize() const;
227
234 inline void* GetImagePtr() const;
235
242 inline cpl_size GetWidth() const;
243
250 inline cpl_size GetHeight() const;
251
258 inline cpl_size GetSize() const;
259
266 inline bool IsImage() const;
267
274 inline bool Status() const;
275
282 inline cpl_type GetCplType() const;
283
290 inline cpl_image *GetCplImage() const;
291
298 void SetCplImage(cpl_image *image);
299
310 void Copy(const Image&,
311 const cpl_size pos_x,
312 const cpl_size pos_y);
313
322 void Save(const std::string filename,
323 cpl_type type=CPL_TYPE_FLOAT);
324
335 void Load(const std::string filename,
336 const cpl_size plane=0,
337 const cpl_size extension=0,
338 cpl_type type=CPL_TYPE_UNSPECIFIED);
339
355 void Load(const std::string filename,
356 const cpl_size llx,
357 const cpl_size lly,
358 const cpl_size urx,
359 const cpl_size ury,
360 const cpl_size plane=0,
361 const cpl_size extension=0,
362 cpl_type type=CPL_TYPE_UNSPECIFIED);
363
364
374 void Unload();
375
376 // Routines to get the pixel value at given position
377
386 double Get(cpl_size xpos, cpl_size ypos) const;
387
396 void Get(cpl_size xpos, cpl_size ypos, double *value);
397
406 void Set(cpl_size xpos, cpl_size ypos, double value);
407
408 // Routines to handle bad pixels
409
416 void SetBadPixelMap(const Mask &mask);
417
424 cpl_size CountBadPixelMap();
425
426 // Basic interface functions to CPL
439 void Exponential(const double base);
440
452 void Logarithm (const double base);
453
465 void Power (const double exponent);
466
478 void Absolute ();
479
495 void Normalise (cpl_norm norm=CPL_NORM_SCALE);
496
508 void Turn (int rotation=-1);
509
521 void FFT (Image *imaginary, unsigned mode=CPL_FFT_DEFAULT);
522
536 void Threshold (double lo_cut,
537 double hi_cut,
538 double assign_lo_cut,
539 double assign_hi_cut);
540
552 void Rebin(cpl_size xstart,
553 cpl_size ystart,
554 cpl_size xstep,
555 cpl_size ystep,
556 Image& new_image);
557
558 // Generation functions
570 void FillNoise(const double min_pix,
571 const double max_pix);
572
587 void FillGaussian(const double cen_x,
588 const double cen_y,
589 const double norm,
590 const double sigma_x,
591 const double sigma_y);
592
593 // Object operators
602 Image& operator+(const double);
603
612 Image& operator+(const Image&);
613
621 Image& operator-(const double);
622
630 Image& operator-(const Image&);
631
640 Image& operator/(const double);
641
649 Image& operator/(const Image&);
650
658 Image& operator*(const double);
659
667 Image& operator*(const Image&);
668
676 Image& operator+=(const double);
677
685 Image& operator+=(const Image&);
686
694 Image& operator-=(const double);
695
703 Image& operator-=(const Image&);
704
712 Image& operator/=(const double);
713
721 Image& operator/=(const Image&);
722
730 Image& operator*=(const double);
731
739 Image& operator*=(const Image&);
740
741
749 Image& operator=(const Image&);
750
757 bool operator==(const Image&) const;
758
765 bool operator!=(const Image&) const;
766
767 protected:
768 cpl_type m_cpl_type;
769 cpl_image* m_cpl_image;
770
771
772 };
773}
774
775#include "image.ipp"
776
777#endif
778
779
780
781
782
783
784
785
This class handle the errors produced by the calling of image processing routines.
Definition error.hpp:34
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:294
void SetBadPixelMap(const Mask &mask)
Set the bad pixel map.
Definition image.cpp:695
cpl_type GetCplType() const
Get CPL image type.
cpl_image * m_cpl_image
Definition image.hpp:769
void Exponential(const double base)
Computes the image exponential.
Definition image.cpp:191
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:321
Image & operator*(const double)
Overload operator*.
Definition image.cpp:466
Image & operator=(const Image &)
Overload operator=.
Definition image.cpp:569
cpl_image * GetCplImage() const
Get CPL image.
Image & operator*=(const double)
Overload operator*=.
Definition image.cpp:547
bool IsImage() const
Check is CPL image is valid.
Image & operator+(const double)
Overload operator+.
Definition image.cpp:405
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:302
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:351
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:335
void Turn(int rotation=-1)
Rotate CPL image.
Definition image.cpp:234
Image & operator/(const double)
Overload operator/.
Definition image.cpp:446
void SetCplImage(cpl_image *image)
Set CPL image.
void Unload()
Release CPL image.
Definition image.cpp:314
bool operator==(const Image &) const
Overload operator==.
Definition image.cpp:593
cpl_size CountBadPixelMap()
Count the bad pixels.
Definition image.cpp:711
virtual ~Image()
Class destructor.
Definition image.cpp:148
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:526
void Absolute()
Computes the image absolute.
Definition image.cpp:218
double Get(cpl_size xpos, cpl_size ypos) const
Get the value of a pixel at a given position.
Definition image.cpp:649
void Set(cpl_size xpos, cpl_size ypos, double value)
Set the value of a pixel at a given position.
Definition image.cpp:682
void Normalise(cpl_norm norm=CPL_NORM_SCALE)
Normalize the CPL image.
Definition image.cpp:226
cpl_type m_cpl_type
Definition image.hpp:768
void Logarithm(const double base)
Computes the image logarithm.
Definition image.cpp:200
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:276
void Power(const double exponent)
Computes the image power.
Definition image.cpp:209
void FFT(Image *imaginary, unsigned mode=CPL_FFT_DEFAULT)
Fast Fourier Transfor of a CPL image.
Definition image.cpp:243
cpl_size GetHeight() const
Get image height.
cpl_size GetSize() const
Get image size.
Image()
Class constructor.
Definition image.cpp:21
Image & operator-(const double)
Overload operator-.
Definition image.cpp:426
Image & operator+=(const double)
Overload operator+=.
Definition image.cpp:486
bool operator!=(const Image &) const
Overload operator!=.
Definition image.cpp:621
Image & operator-=(const double)
Overload operator-=.
Definition image.cpp:506
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:264
cpl_size GetTypeSize() const
Get size of the image built-in type.
Definition image.cpp:167
This class is C++ wrapper for a CPL mask object. It provides a simplified interface that allows to ca...
Definition mask.hpp:37
Array class source file.
Definition array.cpp:14