img::Image< Channels, ScalarType, Safe > Class Template Reference

the generic image class More...

#include <img_image.h>

List of all members.

Public Member Functions

int channels () const
 get the number of channels of the image
ScalarTypedataValues () const
 get a const pointer to the image databuffer
int dataValuesSize () const
 get the size of the image databuffer
void deleteData ()
 delete the image data
void getPixel (int x, int y, ScalarType(&ret_pixel)[Channels]) const
 get all the values of a pixel
void getPixelAsClamped (int x, int y, ScalarType(&ret_pixel)[Channels]) const
 get all the values of a pixel, clamping if the coordinates are out of bounds
ScalarType getValue (int x, int y, int channel) const
 get a single value of a pixel
float getValueAsClamped (int x, int y, int channel) const
 get a single value of a pixel, clamping if the coordinates are out of bounds
int height () const
 get the height of the image
 Image (int arg_width, int arg_height)
 blank image constructor
template<typename OtherScalarType , bool OtherSafe>
 Image (const Image< Channels, OtherScalarType, OtherSafe > &image)
 (deep) copy constructor when some template parameters differs
 Image (const Image< Channels, ScalarType, Safe > &image)
 (deep) copy constructor when all template parameters matches
 Image ()
 default image constructor
bool isInside (float x, float y) const
 checks if the given float coordinates are inside the image bounds
bool isInside (int x, int y) const
 checks if the given coordinates are inside the image bounds
bool isValid () const
 checks if the image has been initialized
void nearestPixel (float x, float y, ScalarType(&ret_pixel)[Channels]) const
 get all the values of a pixel, rounding the floating coordinates to the nearest pixel
template<typename OtherScalarType , bool OtherSafe>
Image< Channels, ScalarType,
Safe > & 
operator= (const Image< Channels, OtherScalarType, OtherSafe > &image)
 assignment operator (deep copy)
void setHeight (int height)
 set the height of the image
void setPixel (int x, int y, const ScalarType(&pixel)[Channels])
 set all the values of a pixel
void setRawValue (int i, ScalarType value)
 set a value in the image databuffer
void setValue (int x, int y, int channel, ScalarType value)
 set a single value of a pixel
void setValues (ScalarType *data)
 set the image databuffer
void setWidth (int width)
 set the width of the image
void setZero (int arg_width, int arg_height)
 blanks and change the image dimensions
int width () const
 get the width of the image
 ~Image ()
 the destructor

Public Attributes

ImgAttributes< ScalarTypeattributes
 the auxiliary structured attribute that contains all the metadata information.

Private Attributes

ScalarType_data
 data buffer
int _height
 height of the image
int _width
 width of the image

Detailed Description

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
class img::Image< Channels, ScalarType, Safe >

the generic image class

The image class is templated over three parameters:

The image data is packed by the pixel, to optimize multichannel processing efficiency. The image class interface is restricted to pixel and metadata access, processing and I/O are entirely delegated to external functions. The data is accessible in multiple ways: value and pixel wise, using float coordinates with nearest and bilinear interpolation, viewing the image with clamping, direct access to the data and so on.

An auxiliary structured attribute contains all the metadata information, currently this data consists in the specification of the numeric range of the values, the image color space, the white point and the gamma compression of the image. The various functions checks these data before processing, failing if the image is not compatible with the operation in course.

Definition at line 26 of file img_image.h.


Constructor & Destructor Documentation

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
img::Image< Channels, ScalarType, Safe >::Image (  )  [inline]

default image constructor

Creates a 0 x 0 pixel image with no data and default attributes

Definition at line 49 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
img::Image< Channels, ScalarType, Safe >::Image ( const Image< Channels, ScalarType, Safe > &  image  )  [inline]

(deep) copy constructor when all template parameters matches

An explicit copy constructor is needed because when all template parameters matches the templated copy constructor is not consideredand and a wrong copy constructor is synthetized by compiler.

Parameters:
image the image to be copied

Definition at line 62 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
template<typename OtherScalarType , bool OtherSafe>
img::Image< Channels, ScalarType, Safe >::Image ( const Image< Channels, OtherScalarType, OtherSafe > &  image  )  [inline]

(deep) copy constructor when some template parameters differs

Parameters:
image the image to be copied

Definition at line 88 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
img::Image< Channels, ScalarType, Safe >::Image ( int  arg_width,
int  arg_height 
) [inline]

blank image constructor

Creates an arg_width x arg_height pixel image with 0-valued data and default attributes

Parameters:
arg_width the width of the blank image
arg_height the height of the blank image

Definition at line 120 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
img::Image< Channels, ScalarType, Safe >::~Image (  )  [inline]

the destructor

Definition at line 138 of file img_image.h.


Member Function Documentation

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
int img::Image< Channels, ScalarType, Safe >::channels (  )  const [inline]

get the number of channels of the image

Returns:
the number of channels of the image

Definition at line 492 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
ScalarType* img::Image< Channels, ScalarType, Safe >::dataValues (  )  const [inline]

get a const pointer to the image databuffer

Warning:
this function exposes the internal structure of the image, mind your accesses.
Returns:
a const pointer to the image databuffer

Definition at line 428 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
int img::Image< Channels, ScalarType, Safe >::dataValuesSize (  )  const [inline]

get the size of the image databuffer

Returns:
the size of the image databuffer

Definition at line 437 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::deleteData (  )  [inline]

delete the image data

Delete the current image data and create an 0 x 0 pixel image with no data.

Definition at line 209 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::getPixel ( int  x,
int  y,
ScalarType(&)  ret_pixel[Channels] 
) const [inline]

get all the values of a pixel

Parameters:
x the horizontal coordinate of the pixel
y the vertical coordinate of the pixel
ret_pixel return parameter that is filled with the pixel values

Definition at line 226 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::getPixelAsClamped ( int  x,
int  y,
ScalarType(&)  ret_pixel[Channels] 
) const [inline]

get all the values of a pixel, clamping if the coordinates are out of bounds

Parameters:
x the horizontal coordinate of the pixel
y the vertical coordinate of the pixel
ret_pixel return parameter that is filled with the pixel values

Definition at line 310 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
ScalarType img::Image< Channels, ScalarType, Safe >::getValue ( int  x,
int  y,
int  channel 
) const [inline]

get a single value of a pixel

Parameters:
x the horizontal coordinate of the pixel
y the vertical coordinate of the pixel
channel the channel index
Returns:
the value of the channel at the pixel

Definition at line 267 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
float img::Image< Channels, ScalarType, Safe >::getValueAsClamped ( int  x,
int  y,
int  channel 
) const [inline]

get a single value of a pixel, clamping if the coordinates are out of bounds

Parameters:
x the horizontal coordinate of the pixel
y the vertical coordinate of the pixel
channel the channel index
Returns:
the value of the channel at the pixel

Definition at line 322 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
int img::Image< Channels, ScalarType, Safe >::height (  )  const [inline]

get the height of the image

Returns:
the height of the image

Definition at line 390 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
bool img::Image< Channels, ScalarType, Safe >::isInside ( float  x,
float  y 
) const [inline]

checks if the given float coordinates are inside the image bounds

Parameters:
x the horizontal coordinate
y the vertical coordinate
Returns:
true if the given coordinates are inside the image bounds, false otherwise

Definition at line 474 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
bool img::Image< Channels, ScalarType, Safe >::isInside ( int  x,
int  y 
) const [inline]

checks if the given coordinates are inside the image bounds

Parameters:
x the horizontal coordinate
y the vertical coordinate
Returns:
true if the given coordinates are inside the image bounds, false otherwise

Definition at line 463 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
bool img::Image< Channels, ScalarType, Safe >::isValid (  )  const [inline]

checks if the image has been initialized

Returns:
true if the data is not null and the minimun side is longer than 0 pixel, false otherwise

Definition at line 483 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::nearestPixel ( float  x,
float  y,
ScalarType(&)  ret_pixel[Channels] 
) const [inline]

get all the values of a pixel, rounding the floating coordinates to the nearest pixel

Parameters:
x the horizontal coordinate of the pixel
y the vertical coordinate of the pixel
ret_pixel return parameter that is filled with the pixel values

Definition at line 333 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
template<typename OtherScalarType , bool OtherSafe>
Image< Channels,ScalarType,Safe>& img::Image< Channels, ScalarType, Safe >::operator= ( const Image< Channels, OtherScalarType, OtherSafe > &  image  )  [inline]

assignment operator (deep copy)

Parameters:
image the image to be assigned to this instance
Returns:
a pointer to this instance

Definition at line 155 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::setHeight ( int  height  )  [inline]

set the height of the image

Warning:
changing the image size without changing the data buffer accordingly can lead to memory errors
Parameters:
height the new height of the image

Definition at line 414 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::setPixel ( int  x,
int  y,
const ScalarType(&)  pixel[Channels] 
) [inline]

set all the values of a pixel

Parameters:
x the horizontal coordinate of the pixel
y the vertical coordinate of the pixel
pixel the pixel values that are assigned to the pixel

Definition at line 246 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::setRawValue ( int  i,
ScalarType  value 
) [inline]

set a value in the image databuffer

Warning:
this function modifies the internal structure of the image!
Parameters:
i the index of the databuffer
value the value to set in the i position of the databuffer

Definition at line 503 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::setValue ( int  x,
int  y,
int  channel,
ScalarType  value 
) [inline]

set a single value of a pixel

Parameters:
x the horizontal coordinate of the pixel
y the vertical coordinate of the pixel
channel the channel index
value the value that is assigned to the channel at the pixel

Definition at line 289 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::setValues ( ScalarType data  )  [inline]

set the image databuffer

Warning:
this function modifies the internal structure of the image!
Parameters:
data a pointer to the new image databuffer

Definition at line 448 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::setWidth ( int  width  )  [inline]

set the width of the image

Warning:
changing the image size without changing the data buffer accordingly can lead to memory errors
Parameters:
width the new width of the image

Definition at line 400 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
void img::Image< Channels, ScalarType, Safe >::setZero ( int  arg_width,
int  arg_height 
) [inline]

blanks and change the image dimensions

Delete the current image data and create an arg_width x arg_height pixel image with 0-valued data and default attributes

Parameters:
arg_width the width of the blank image
arg_height the height of the blank image

Definition at line 184 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
int img::Image< Channels, ScalarType, Safe >::width (  )  const [inline]

get the width of the image

Returns:
the width of the image

Definition at line 381 of file img_image.h.


Member Data Documentation

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
ScalarType* img::Image< Channels, ScalarType, Safe >::_data [private]

data buffer

Definition at line 37 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
int img::Image< Channels, ScalarType, Safe >::_height [private]

height of the image

Definition at line 35 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
int img::Image< Channels, ScalarType, Safe >::_width [private]

width of the image

Definition at line 33 of file img_image.h.

template<int Channels = 3, typename ScalarType = double, bool Safe = true>
ImgAttributes<ScalarType> img::Image< Channels, ScalarType, Safe >::attributes

the auxiliary structured attribute that contains all the metadata information.

Definition at line 42 of file img_image.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


vcglib
Author(s): Christian Bersch
autogenerated on Fri Jan 11 09:22:44 2013