ddt 1.2.1
Loading...
Searching...
No Matches
imageIO.cpp File Reference

Image IO function declaration. This file is part of the DDT Image Handling Library and provides functions to load / save CPL images. More...

#include "ddt/imageIO.hpp"
#include <cstring>

Functions

cpl_vector * LoadCplVector (const char *file_name, long long extension_number)
 
cpl_image * LoadCplImage (const char *file_name, long long plane_number, long long extension_number)
 
cpl_image * CreateCplImage (int width, int height, uint8_t *image_data)
 
cpl_image * CreateCplImage (int width, int height, std::vector< uint8_t > *image_data)
 
cpl_image * CreateCplImage (int width, int height, int16_t *image_data)
 
cpl_image * CreateCplImage (int width, int height, std::vector< int16_t > *image_data)
 
cpl_image * CreateCplImage (const int width, const int height, int32_t *const image_data)
 
cpl_image * CreateCplImage (int width, int height, std::vector< int32_t > *image_data)
 
cpl_image * CreateCplImage (const int width, const int height, float *const image_data)
 
cpl_image * CreateCplImage (int width, int height, std::vector< float > *image_data)
 
cpl_image * CreateCplImage (const int width, const int height, double *const image_data)
 
cpl_image * CreateCplImage (int width, int height, std::vector< double > *image_data)
 
cpl_image * CreateCplImage (const int width, const int height, uint16_t *const image_data)
 
cpl_image * CreateCplImage (const int width, const int height, std::vector< uint16_t > *const image_data)
 
cpl_image * CreateCplImage (const int width, const int height, uint32_t *const image_data)
 
cpl_image * CreateCplImage (const int width, const int height, std::vector< uint32_t > *const image_data)
 
bool SaveCplImage (const cpl_image *image, const char *file_name, cpl_propertylist *property_list)
 
void DeleteCplImage (cpl_image *image)
 
void UnwrapCplImage (cpl_image *image)
 
void DeleteCplPropertyList (cpl_propertylist *const propertylist)
 
cpl_type GetCplImageType (const cpl_image *image)
 
int GetCplImageExtensions (const char *file_name)
 
cpl_propertylist * GetCplImagePropertyList (const char *file_name, int position)
 
int GetCplImagePlanCount (const cpl_propertylist *propertylist)
 
cpl_wcs * GetCplWcs (const cpl_propertylist *propertylist)
 
int GetCplImageBitPix (const cpl_propertylist *const propertylist)
 

Detailed Description

Image IO function declaration. This file is part of the DDT Image Handling Library and provides functions to load / save CPL images.

Author
Christoph Bortlisz, CGI
Since
2020/07/29

Function Documentation

◆ CreateCplImage() [1/14]

cpl_image * CreateCplImage ( const int width,
const int height,
double *const image_data )

Creates an image from a vector of 32 bit float data. Call function UnwrapCplImage to deallocate memory afterwards.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [2/14]

cpl_image * CreateCplImage ( const int width,
const int height,
float *const image_data )

Creates an image from a vector of float data. Call function UnwrapCplImage to deallocate memory afterwards.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [3/14]

cpl_image * CreateCplImage ( const int width,
const int height,
int32_t *const image_data )

Creates an image from a vector of 16 bit signed data. Call function UnwrapCplImage to deallocate memory afterwards.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [4/14]

cpl_image * CreateCplImage ( const int width,
const int height,
std::vector< uint16_t > *const image_data )

Creates an image from a vector of 16 bit unsigned data. Call function DeleteCplImage to deallocate memory afterwards. Note that the created image has the CPL_TYPE_FLOAT data type.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [5/14]

cpl_image * CreateCplImage ( const int width,
const int height,
std::vector< uint32_t > *const image_data )

Creates an image from a vector of 32 bit unsigned data. Call function DeleteCplImage to deallocate memory afterwards. Note that the created image has the CPL_TYPE_DOUBLE data type.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [6/14]

cpl_image * CreateCplImage ( const int width,
const int height,
uint16_t *const image_data )

Creates an image from a vector of 16 bit unsigned int data. Call function DeleteCplImage to deallocate memory afterwards. Note that the created image has the CPL_TYPE_FLOAT data type.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [7/14]

cpl_image * CreateCplImage ( const int width,
const int height,
uint32_t *const image_data )

Creates an image from a vector of 32 bit unsigned int data. Call function DeleteCplImage to deallocate memory afterwards. Note that the created image has the CPL_TYPE_DOUBLE data type.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [8/14]

cpl_image * CreateCplImage ( int width,
int height,
int16_t * image_data )

Creates an image from a vector of 16 bit signed data. Call function DeleteCplImage to deallocate memory afterwards.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [9/14]

cpl_image * CreateCplImage ( int width,
int height,
std::vector< double > * image_data )

Creates an image from a vector of 64 bit double data. Call function UnwrapCplImage to deallocate memory afterwards.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [10/14]

cpl_image * CreateCplImage ( int width,
int height,
std::vector< float > * image_data )

Creates an image from a vector of 32 bit float data. Call function UnwrapCplImage to deallocate memory afterwards.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [11/14]

cpl_image * CreateCplImage ( int width,
int height,
std::vector< int16_t > * image_data )

Creates an image from a vector of 16 bit signed data. Call function DeleteCplImage to deallocate memory afterwards.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [12/14]

cpl_image * CreateCplImage ( int width,
int height,
std::vector< int32_t > * image_data )

Creates an image from a vector of 32 bit signed data. Call function UnwrapCplImage to deallocate memory afterwards.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [13/14]

cpl_image * CreateCplImage ( int width,
int height,
std::vector< uint8_t > * image_data )

Creates an image from a vector of 8 bit unsigned data. Call function DeleteCplImage to deallocate memory afterwards.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ CreateCplImage() [14/14]

cpl_image * CreateCplImage ( int width,
int height,
uint8_t * image_data )

Creates an image from a vector of 8 bit unsigned data. Call function DeleteCplImage to deallocate memory afterwards.

Parameters
widththe number of columns in the image
heightthe number of lines in the image
image_dataaddress of the data vector
Returns
newly allocated CPL image or NULL on error

◆ DeleteCplImage()

void DeleteCplImage ( cpl_image * image)

Unwraps the image (frees memory associated with the image) and deallocates the pixel buffer

Parameters
imageCPL image object

◆ DeleteCplPropertyList()

void DeleteCplPropertyList ( cpl_propertylist *const propertylist)

Destroy a property list.

Parameters
propertylistthe property list to be destroyed

◆ GetCplImageBitPix()

int GetCplImageBitPix ( const cpl_propertylist *const propertylist)

Get the number of bits per pixel as contained in the property list of a CPL image (FITS). The property list has to be loaded from a certain data set contained in a CPL image.

Parameters
propertylistCPL image property list
Returns
number of bits per pixel as contained in the cpl_property_list object (BITPIX value, or ZBITPIX for compressed images), or 0 on error

◆ GetCplImageExtensions()

int GetCplImageExtensions ( const char * file_name)

Get the number of extensions from a CPL image (FITS).

Parameters
file_nameFilename of the image to check
Returns
the number of extensions in the CPL image, or -1 on error

◆ GetCplImagePlanCount()

int GetCplImagePlanCount ( const cpl_propertylist * propertylist)

Get the number of planes as contained in the property list of a CPL image (FITS). The property list has to be loaded from a certain data set contained in a CPL image. The function will return following values depending on the number of axis contained: number of axis: 1: -> 0 number of axis: 2: -> 1 number of axis: 3: -> value of property NAXIS3 number of axis > 3: -> -1

Parameters
propertylistCPL image property list
Returns
number of planes as contained in the cpl_property_list object, or -1 on error

◆ GetCplImagePropertyList()

cpl_propertylist * GetCplImagePropertyList ( const char * file_name,
int position )

Get the property list from one data set of a CPL image (FITS).

Parameters
file_nameFilename of the image
positionindex of the data set (defaults to 0)
Returns
a cpl_property_list object, or NULL on error

◆ GetCplImageType()

cpl_type GetCplImageType ( const cpl_image * image)

Get the image type from a CPL image.

Parameters
imageCPL image object
Returns
the image type or CPL_TYPE_INVALID

◆ GetCplWcs()

cpl_wcs * GetCplWcs ( const cpl_propertylist * propertylist)

Get the WCS structure created by parsing a CPL property list.

Parameters
propertylistthe input property list
Returns
the cpl_wcs object, or NULL in case of error.

◆ LoadCplImage()

cpl_image * LoadCplImage ( const char * file_name,
long long plane_number,
long long extension_number )

Loads an image from a fits file.

Parameters
file_nameFilename of the image to load
plane_numberPlane number in the Data Unit (default 0: first)
extension_numberExtension number in the file (default 0: primary HDU)
Returns
newly allocated CPL image or NULL on error

◆ LoadCplVector()

cpl_vector * LoadCplVector ( const char * file_name,
long long extension_number )

This file is part of the DDT Image Handling Library and provides functions to load / save CPL images. Loads a vector from a fits file.

Parameters
file_nameFilename of the image to load
extension_numberExtension number in the file (default 0: primary HDU)
Returns
newly allocated CPL vector or NULL on error

◆ SaveCplImage()

bool SaveCplImage ( const cpl_image * image,
const char * file_name,
cpl_propertylist * property_list )

Save an image to a fits file.

Parameters
imageCPL image object
file_nameFilename of the file to save to
property_listlist of properties to save to the output header
Returns
bool indicating success of saving

◆ UnwrapCplImage()

void UnwrapCplImage ( cpl_image * image)

Unwraps the image (frees memory associated with the image, except the pixel buffer). The pixel buffer must subsequently be deallocated.

Parameters
imageCPL image object