ifw-odp  2.0.0-alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
odp::Image Class Reference

This class is C++ wrapper for a CPL image object. It provides a simplified interface that allows to call CPL routines from from INS applications. More...

#include <image.hpp>

Inheritance diagram for odp::Image:
odp::Error odp::ImageWrapper< T >

Public Member Functions

 Image ()
 Class constructor. More...
 
 Image (const cpl_size size_x, const cpl_size size_y, const cpl_type type)
 Class constructor. More...
 
 Image (const Image &image)
 Copy constructor. More...
 
 Image (const Mask &mask)
 Copy constructor. More...
 
 Image (const Image &image, cpl_type type)
 Copy constructor. More...
 
 Image (const Image &image, const cpl_size llx, const cpl_size lly, const cpl_size urx, const cpl_size ury)
 Copy constructor. More...
 
 Image (const Mask &mask, const cpl_size llx, const cpl_size lly, const cpl_size urx, const cpl_size ury)
 Copy constructor. More...
 
 Image (const Image *image, const cpl_size llx, const cpl_size lly, const cpl_size urx, const cpl_size ury)
 Copy constructor. More...
 
 Image (const Image *image, const cpl_size startx, const cpl_size starty, const cpl_size size_single_det_x, const cpl_size size_single_det_y, const cpl_size size_gap_x, const cpl_size size_gap_y)
 Copy constructor. More...
 
virtual ~Image ()
 Class destructor. More...
 
void GetImagePtr (void **data_ptr) const
 Get pointer to image data. More...
 
cpl_size GetTypeSize () const
 Get size of the image built-in type. More...
 
void * GetImagePtr () const
 Get pointer to image data. More...
 
cpl_size GetWidth () const
 Get image width. More...
 
cpl_size GetHeight () const
 Get image height. More...
 
cpl_size GetSize () const
 Get image size. More...
 
bool IsImage () const
 Check is CPL image is valid. More...
 
bool Status () const
 Get image status. More...
 
cpl_type GetCplType () const
 Get CPL image type. More...
 
cpl_image * GetCplImage () const
 Get CPL image. More...
 
void SetCplImage (cpl_image *image)
 Set CPL image. More...
 
void Copy (const Image &, const cpl_size pos_x, const cpl_size pos_y)
 Copy input image object in the coordinates specified. More...
 
void Save (const std::string filename, cpl_type type=CPL_TYPE_FLOAT)
 Save CPL image into a FITS file. More...
 
void Load (const std::string filename, const cpl_size plane=0, const cpl_size extension=0, cpl_type type=CPL_TYPE_FLOAT)
 Load CPL image from a FITS file. More...
 
void Load (const std::string filename, const cpl_size llx, const cpl_size lly, const cpl_size urx, const cpl_size ury, const cpl_size plane=0, const cpl_size extension=0, cpl_type type=CPL_TYPE_FLOAT)
 Load CPL image from a FITS file subwindow. More...
 
void Unload ()
 Release CPL image. More...
 
double Get (cpl_size xpos, cpl_size ypos) const
 Get the value of a pixel at a given position. More...
 
void Get (cpl_size xpos, cpl_size ypos, double *value)
 Get the value of a pixel at a given position. More...
 
void Set (cpl_size xpos, cpl_size ypos, double value)
 Set the value of a pixel at a given position. More...
 
void SetBadPixelMap (const Mask &mask)
 Set the bad pixel map. More...
 
cpl_size CountBadPixelMap ()
 Count the bad pixels. More...
 
void Exponential (const double base)
 Computes the image exponential. More...
 
void Logarithm (const double base)
 Computes the image logarithm. More...
 
void Power (const double exponent)
 Computes the image power. More...
 
void Absolute ()
 Computes the image absolute. More...
 
void Normalise (cpl_norm norm=CPL_NORM_SCALE)
 Normalize the CPL image. More...
 
void Turn (int rotation=-1)
 Rotate CPL image. More...
 
void FFT (Image *imaginary, unsigned mode=CPL_FFT_DEFAULT)
 Fast Fourier Transfor of a CPL image. More...
 
void Threshold (double lo_cut, double hi_cut, double assign_lo_cut, double assign_hi_cut)
 Threshold a CPL image to a given interval. More...
 
void Rebin (cpl_size xstart, cpl_size ystart, cpl_size xstep, cpl_size ystep, Image &new_image)
 Image rebin. More...
 
void FillNoise (const double min_pix, const double max_pix)
 It generates a CPL image with uniform random noise distribution. More...
 
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. More...
 
Imageoperator+ (const double)
 Overload operator+. More...
 
Imageoperator+ (const Image &)
 Overload operator+. More...
 
Imageoperator- (const double)
 Overload operator-. More...
 
Imageoperator- (const Image &)
 Overload operator-. More...
 
Imageoperator/ (const double)
 Overload operator/. More...
 
Imageoperator/ (const Image &)
 Overload operator/. More...
 
Imageoperator* (const double)
 Overload operator*. More...
 
Imageoperator* (const Image &)
 Overload operator*. More...
 
Imageoperator+= (const double)
 Overload operator+=. More...
 
Imageoperator+= (const Image &)
 Overload operator+=. More...
 
Imageoperator-= (const double)
 Overload operator-=. More...
 
Imageoperator-= (const Image &)
 Overload operator-=. More...
 
Imageoperator/= (const double)
 Overload operator/=. More...
 
Imageoperator/= (const Image &)
 Overload operator/=. More...
 
Imageoperator*= (const double)
 Overload operator*=. More...
 
Imageoperator*= (const Image &)
 Overload operator*=. More...
 
Imageoperator= (const Image &)
 Overload operator=. More...
 
bool operator== (const Image &) const
 Overload operator==. More...
 
bool operator!= (const Image &) const
 Overload operator!=. More...
 
- Public Member Functions inherited from odp::Error
 Error ()
 Class constructor. More...
 
virtual ~Error ()
 Class destructor. More...
 
void ResetCplError ()
 Reset CPL error and internal error flag. More...
 
bool CheckCplError () const
 Check if there is an error in CPL. More...
 

Protected Attributes

cpl_type m_cpl_type
 
cpl_image * m_cpl_image
 

Additional Inherited Members

- Protected Member Functions inherited from odp::Error
void AddCplError () const
 Add CPL error to the error stack. More...
 
std::string GetErrorMsg () const
 Get CPL error message. More...
 
- Static Protected Member Functions inherited from odp::Error
static void DumpError (unsigned self, unsigned first, unsigned last)
 Dump current CPL error. More...
 

Detailed Description

This class is C++ wrapper for a CPL image object. It provides a simplified interface that allows to call CPL routines from from INS applications.

Image - CPL image wrapper class

See Also
CPL Reference: http://www.eso.org/observing/cpl/reference_3.0/ or above

Constructor & Destructor Documentation

odp::Image::Image ( )

Class constructor.

Returns
none
odp::Image::Image ( const cpl_size  size_x,
const cpl_size  size_y,
const cpl_type  type 
)
explicit

Class constructor.

Parameters
[in]size_xWidth of the CPL image.
[in]size_yHeight of the CPL image.
[in]typeType of the CPL image.
Returns
none

Allocates the CPL image according to the dimensions and type specified.

See Also
CPL function: cpl_image_new
odp::Image::Image ( const Image image)
explicit

Copy constructor.

Parameters
[in]imageObject to be copied.
Returns
none

CPL image is duplicated

See Also
CPL function: cpl_image_duplicate
odp::Image::Image ( const Mask mask)
explicit

Copy constructor.

Parameters
[in]maskobject to be copied.
Returns
none

CPL image is created from a mask object

See Also
CPL function: cpl_image_new_from_mask
odp::Image::Image ( const Image image,
cpl_type  type 
)
explicit

Copy constructor.

Parameters
[in]imageObject to be copied.
[in]typeType of the CPL image. If the type choosen is not the same of the source image, image will be casted.
Returns
none

CPL image of type specified is created.

See Also
CPL function: cpl_image_duplicate
odp::Image::Image ( const Image image,
const cpl_size  llx,
const cpl_size  lly,
const cpl_size  urx,
const cpl_size  ury 
)
explicit

Copy constructor.

Parameters
[in]imageReference object to be copied.
[in]llxLower left X coordinate.
[in]llyLower left Y coordinate.
[in]urxUpper right X coordinate.
[in]uryUpper right Y coordinate.
Returns
none
    Copy constructor that allows to get an image object from a
    window of the input image. Please note that these function
    might fail if the window is too small (CPL problem). Input
    is a reference of an image object.
See Also
CPL function: cpl_image_extract
odp::Image::Image ( const Mask mask,
const cpl_size  llx,
const cpl_size  lly,
const cpl_size  urx,
const cpl_size  ury 
)
explicit

Copy constructor.

Parameters
[in]maskreference object to be copied.
[in]llxLower left X coordinate.
[in]llyLower left Y coordinate.
[in]urxUpper right X coordinate.
[in]uryUpper right Y coordinate.
Returns
none
    Copy constructor that allows to get an image object from a
    mask image. Please note that these function
    might fail if the window is too small (CPL problem). Input
    is a reference of an image object.
See Also
CPL function: cpl_image_extract
odp::Image::Image ( const Image image,
const cpl_size  llx,
const cpl_size  lly,
const cpl_size  urx,
const cpl_size  ury 
)
explicit

Copy constructor.

Parameters
[in]imagePointer to the object to be copied.
[in]llxLower left X coordinate.
[in]llyLower left Y coordinate.
[in]urxUpper right X coordinate.
[in]uryUpper right Y coordinate.
Returns
none
    Copy constructor that allows to get an image object from a
    window of the input image. Please note that these function
    might fail if the window is too small (CPL problem). Input
    is a reference of an image object.
See Also
CPL function: cpl_image_extract
odp::Image::Image ( const Image image,
const cpl_size  startx,
const cpl_size  starty,
const cpl_size  size_single_det_x,
const cpl_size  size_single_det_y,
const cpl_size  size_gap_x,
const cpl_size  size_gap_y 
)
explicit

Copy constructor.

Parameters
[in]imagePointer to the object to be copied.
[in]startxInitial X position
[in]startyInitial Y position
[in]size_single_det_xSize along X of a single detector (pixels).
[in]size_single_det_ySize along Y of a single detector (pixels).
[in]size_gap_xSize along X of the gap (pixels).
[in]size_gap_ySize along Y of the gap (pixels).
Returns
none
    Special copy constructor that will create the new object
    based on the input but introducing an artificial gap in the
    image. This functionality is useful when it is needed to
    visualize the gap of a CCD mosaic.
See Also
CLIPM function: clipm_image_display_insert_gaps
odp::Image::~Image ( )
virtual

Class destructor.

Returns
none
See Also
CPL function: cpl_image_delete

Member Function Documentation

void odp::Image::Absolute ( )

Computes the image absolute.

Returns
none

Interface to CPL image absolute function. It modifies the internal CPL by setting each pixel of the image object to its absolute value.

See Also
CPL function: cpl_image_abs
void odp::Image::Copy ( const Image image,
const cpl_size  pos_x,
const cpl_size  pos_y 
)

Copy input image object in the coordinates specified.

Parameters
[in]imageImage to be copied.
[in]pos_xCoordinate X where the image will be copied.
[in]pos_yCoordinate Y where the image will be copied.
Returns
none
See Also
CPL function: cpl_image_copy
cpl_size odp::Image::CountBadPixelMap ( )

Count the bad pixels.

Returns
Number of bad pixels.
See Also
CPL function:cpl_image_count_rejected
void odp::Image::Exponential ( const double  base)

Computes the image exponential.

Parameters
[in]baseBase of the exponential used in the computation.
Returns
none

Interface to CPL exponential function. It modifies the internal CPL image object by computing the base-scalar exponential of each of its pixels.

See Also
CPL function: cpl_image_exponential
void odp::Image::FFT ( Image imaginary,
unsigned  mode = CPL_FFT_DEFAULT 
)

Fast Fourier Transfor of a CPL image.

Parameters
[in,out]imaginaryThe image imaginary part.
[in]modethe desired FFT options
Returns
none

Interface to CPL image FFT function.

See Also
CPL function: cpl_image_fft
void odp::Image::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.

Parameters
[in]cen_xCenter position along X of the gaussian.
[in]cen_yCenterl position along Y of the gaussian.
[in]normNorm of the gaussian.
[in]sigma_xSigma along X of the gaussian.
[in]sigma_ySigma along Y of the gaussian.

Interface to CPL image generation function. It generates an image from a 2d gaussian function.

See Also
CPL function: cpl_image_fill_gaussian
void odp::Image::FillNoise ( const double  min_pix,
const double  max_pix 
)

It generates a CPL image with uniform random noise distribution.

Parameters
[in]min_pixMinimum pixel value in the generated image.
[in]max_pixMaximum pixel value in the generated image.

Interface to CPL image generation function. It generates an image with uniform random noise distribution.

See Also
CPL function: cpl_image_fill_noise_uniform
double odp::Image::Get ( cpl_size  xpos,
cpl_size  ypos 
) const

Get the value of a pixel at a given position.

Parameters
[in]xposPixel x position (FITS convention, 1 for leftmost)
[in]yposPixel y position (FITS convention, 1 for lowest)
Returns
the value of the pixel.
See Also
CPL function: cpl_image_get
void odp::Image::Get ( cpl_size  xpos,
cpl_size  ypos,
double *  value 
)

Get the value of a pixel at a given position.

Parameters
[in]xposPixel x position (FITS convention, 1 for leftmost)
[in]yposPixel y position (FITS convention, 1 for lowest)
[out]valueThe pixel value
See Also
CPL function: cpl_image_get
cpl_image* odp::Image::GetCplImage ( ) const
inline

Get CPL image.

Returns
CPL image
cpl_type odp::Image::GetCplType ( ) const
inline

Get CPL image type.

Returns
CPL type
cpl_size odp::Image::GetHeight ( ) const
inline

Get image height.

Returns
Image height
void odp::Image::GetImagePtr ( void **  data_ptr) const

Get pointer to image data.

Parameters
[out]data_ptrPointer to the image data
Returns
none
See Also
CPL function: cpl_image_get_data
void* odp::Image::GetImagePtr ( ) const
inline

Get pointer to image data.

Returns
Pointer to the image data.
cpl_size odp::Image::GetSize ( ) const
inline

Get image size.

Returns
Image size
cpl_size odp::Image::GetTypeSize ( ) const

Get size of the image built-in type.

Returns
Image built-in type size
cpl_size odp::Image::GetWidth ( ) const
inline

Get image width.

Returns
Image width
bool odp::Image::IsImage ( ) const
inline

Check is CPL image is valid.

Returns
TRUE is CPL image is not nullptr, FALSE otherwise.
void odp::Image::Load ( const std::string  filename,
const cpl_size  plane = 0,
const cpl_size  extension = 0,
cpl_type  type = CPL_TYPE_FLOAT 
)

Load CPL image from a FITS file.

Parameters
[in]filenameAbsolute or relative path name of the file to be loaded.
[in]planePlane number to be loaded, default is zero.
[in]extensionExtension id to be loaded, default is zero.
[in]typeCPL type used to store the input image, default is FLOAT.
See Also
CPL function: cpl_image_load
void odp::Image::Load ( const std::string  filename,
const cpl_size  llx,
const cpl_size  lly,
const cpl_size  urx,
const cpl_size  ury,
const cpl_size  plane = 0,
const cpl_size  extension = 0,
cpl_type  type = CPL_TYPE_FLOAT 
)

Load CPL image from a FITS file subwindow.

Parameters
[in]filenameAbsolute or relative path name of the file to be loaded.
[in]llxLower left X coordinate
[in]llyLower left Y coordinate
[in]urxUpper right X coordinate
[in]uryUpper right Y coordinate
[in]planePlane number of the cube to be loaded, default is zero for non cube files.
[in]extensionExtension number to be loaded, default is zero.
[in]typeCPL type used to store the input image, default is FLOAT.
Returns
none
See Also
CPL function: cpl_image_load_window
void odp::Image::Logarithm ( const double  base)

Computes the image logarithm.

Parameters
[in]baseBase of the logarithm used in the computation.
Returns
none

Interface to CPL logarihm function. It modifies the internal CPL image by computing the base-scalar logarithm of each of its pixels.

See Also
CPL function: cpl_image_logarithm
void odp::Image::Normalise ( cpl_norm  norm = CPL_NORM_SCALE)

Normalize the CPL image.

Parameters
[in]normNormalization according to the CPL definition.
Returns
none

Interface to CPL image normalise function. It modifies the internal CPL by normalizing the internal image object according to certain criteria.

    CPL_NORM_SCALE sets the pixel interval to [0,1].
    CPL_NORM_MEAN sets the mean value to 1.
    CPL_NORM_FLUX sets the flux to 1.
    CPL_NORM_ABSFLUX sets the absolute flux to 1.
See Also
CPL function: cpl_image_normalise
bool odp::Image::operator!= ( const Image image) const

Overload operator!=.

Parameters
[in]imageInput image to be compared
Returns
Reference to the object
Image & odp::Image::operator* ( const double  scalar)

Overload operator*.

Parameters
[in]scalarInput scalar to be multiplied
Returns
Reference to the object
See Also
CPL function: cpl_image_multiply_scalar
Image & odp::Image::operator* ( const Image image)

Overload operator*.

Parameters
[in]imageInput image to be multiplied
Returns
Reference to the object
See Also
CPL function: cpl_image_multiply
Image & odp::Image::operator*= ( const double  scalar)

Overload operator*=.

Parameters
[in]scalarInput scalar to be multiplied
Returns
Reference to the object
See Also
CPL function: cpl_image_multiply_scalar
Image & odp::Image::operator*= ( const Image image)

Overload operator*=.

Parameters
[in]imageInput image to be multiplied
Returns
Reference to the object
See Also
CPL function: cpl_image_multiply
Image & odp::Image::operator+ ( const double  scalar)

Overload operator+.

Parameters
[in]scalarInput number to be added.
Returns
Reference to the object
See Also
CPL function: cpl_image_add_scalar
Image & odp::Image::operator+ ( const Image image)

Overload operator+.

Parameters
[in]imageInput image to be added
Returns
Reference to the object
See Also
CPL function: cpl_image_add
Image & odp::Image::operator+= ( const double  scalar)

Overload operator+=.

Parameters
[in]scalarInput scalar to be added
Returns
Reference to the object
See Also
CPL function: cpl_image_add_scalar
Image & odp::Image::operator+= ( const Image image)

Overload operator+=.

Parameters
[in]imageInput image to be added
Returns
Reference to the object
See Also
CPL function: cpl_image_add
Image & odp::Image::operator- ( const double  scalar)

Overload operator-.

Parameters
[in]scalarInput number to be subtracted.
Returns
Reference to the object
See Also
CPL function: cpl_image_subtract_scalar
Image & odp::Image::operator- ( const Image image)

Overload operator-.

Parameters
[in]imageInput image to be subtracted
Returns
Reference to the object
See Also
CPL function: cpl_image_subtract
Image & odp::Image::operator-= ( const double  scalar)

Overload operator-=.

Parameters
[in]scalarInput scalar to be subtracted
Returns
Reference to the object
See Also
CPL function: cpl_image_subtract_scalar
Image & odp::Image::operator-= ( const Image image)

Overload operator-=.

Parameters
[in]imageInput image to be subtracted
Returns
Reference to the object
See Also
CPL function: cpl_image_subtract
Image & odp::Image::operator/ ( const double  scalar)

Overload operator/.

Parameters
[in]scalarInput number to be divided
Returns
Reference to the object
See Also
CPL function: cpl_image_divide_scalar
Image & odp::Image::operator/ ( const Image image)

Overload operator/.

Parameters
[in]imageInput image to be divided
Returns
Reference to the object
See Also
CPL function: cpl_image_divide
Image & odp::Image::operator/= ( const double  scalar)

Overload operator/=.

Parameters
[in]scalarInput scalar to be divided
Returns
Reference to the object
See Also
CPL function: cpl_image_divide_scalar
Image & odp::Image::operator/= ( const Image image)

Overload operator/=.

Parameters
[in]imageInput image to be divided
Returns
Reference to the object
See Also
CPL function: cpl_image_divide
Image & odp::Image::operator= ( const Image image)

Overload operator=.

Parameters
[in]imageInput image to be copied
Returns
Reference to the object
See Also
CPL function: cpl_image_duplicate
bool odp::Image::operator== ( const Image image) const

Overload operator==.

Parameters
[in]imageInput image to be compared
Returns
Reference to the object
void odp::Image::Power ( const double  exponent)

Computes the image power.

Parameters
[in]exponentExponent used in the computation of the power.
Returns
none

Interface to CPL image power function. It modifies the internal CPL by lifting each of its pixels to exponent.

See Also
CPL function: cpl_image_power
void odp::Image::Rebin ( cpl_size  xstart,
cpl_size  ystart,
cpl_size  xstep,
cpl_size  ystep,
Image new_image 
)

Image rebin.

Parameters
[in]xstartstart x position of binning
[in]ystartstart y position of binning
[in]xstepbin size along x.
[in]ystepbin size along y.
[out]new_imageoutput rebin image.
See Also
CPL function: cpl_image_rebin
void odp::Image::Save ( const std::string  filename,
cpl_type  type = CPL_TYPE_FLOAT 
)

Save CPL image into a FITS file.

Parameters
[in]filenameAbsolute path name of the file to be saved.
[in]typeData type of the image to be saved.
See Also
CPL function: cpl_image_save
void odp::Image::Set ( cpl_size  xpos,
cpl_size  ypos,
double  value 
)

Set the value of a pixel at a given position.

Parameters
[in]xposPixel x position (FITS convention, 1 for leftmost)
[in]yposPixel y position (FITS convention, 1 for lowest)
[in]valueThe pixel value
See Also
CPL function: cpl_image_set
void odp::Image::SetBadPixelMap ( const Mask mask)

Set the bad pixel map.

Parameters
[in]maskInpu mask containing the bad pixels.
See Also
CPL function: cpl_image_reject_from_mask
void odp::Image::SetCplImage ( cpl_image *  image)

Set CPL image.

Parameters
[in]imageCPL image
Returns
none
bool odp::Image::Status ( ) const
inline

Get image status.

Returns
TRUE is CPL image is valid, FALSE otherwise.
void odp::Image::Threshold ( double  lo_cut,
double  hi_cut,
double  assign_lo_cut,
double  assign_hi_cut 
)

Threshold a CPL image to a given interval.

Parameters
[in]lo_cutLower bound
[in]hi_cutHigher bound
[in]assign_lo_cutValue to assign to pixels below low bound.
[in]assign_hi_cutValue to assign to pixels above high bound.

Interface to CPL threshold function.

See Also
CPL function: cpl_image_threshold
void odp::Image::Turn ( int  rotation = -1)

Rotate CPL image.

Parameters
[in]rotationMultiple of 90 degrees to rotate.
Returns
none

Interface to CPL image turn function. It rotates the image object by a multiple of 90 deg clockwise.

See Also
CPL function: cpl_image_turn
void odp::Image::Unload ( )

Release CPL image.

Returns
none
    Delete image object from memory.
See Also
CPL function: cpl_image_delete

Member Data Documentation

cpl_image* odp::Image::m_cpl_image
protected
cpl_type odp::Image::m_cpl_type
protected

The documentation for this class was generated from the following files: