# opentl::core::cvdata::Image Class Reference

Class for Image Storage. More...

Inherits opentl::core::cvdata::TimedData.

Inherited by opentl::core::cvdata::TiledImage.

List of all members.

## Public Types
## Public Member Functions
std::size_t | allocatedBytes () const
| Return the number of bytes allocated for this Image.
std::size_t | allocatedHeight () const
| This value should be equal to the mHeight of the picture.
std::size_t | allocatedWidth () const
| Return the number of bytes for a horizontal picture line.
BitsPerChannel | bitsPerChannel () const
| Return the number of bits per channel.
void | blendImage (const Image &imageToBlend, CvRect *pDestArea, CvRect *srcArea=NULL, double dOpacity=1.0)
ColorChannels | channels () const
| Return color mChannels of this image.
virtual Image * | clone () const
void | dumpIplImage (char *windowName=NULL, int delay=0)
| Dump contents into an OpenCv window, and wait for a pressed key to exit.
void | fillZero ()
| Fill image with 0 values.
std::size_t | height () const
| Return the mHeight of the picture.
| Image (std::string filename)
| Create an Image from a file.
| Image (const Image &image)
| Copy Constructor.
| Image (const IplImage *image)
| Create an Image based on an OpenCV image.
| Image (int initWidth=1, int initHeight=1, ColorChannels initChannels=RGB, BitsPerChannel bpc=BPC8U)
| Create an Image with the given dimensions and number of mChannels.
unsigned char * | imageBuffer () const
| Return a pointer to the internal image buffer.
IplImage * | iplImage () const
| Return a pointer to this image in a form which is compatible with OpenCV.
virtual std::size_t | nofChannels () const
| set number of color mChannels of this image.
unsigned char & | operator() (unsigned x, unsigned y, unsigned channel)
| Random Pixel Access.
Image & | operator= (const Image &img)
| Random Pixel Access.
void | resizeMemory (const int newWidth, const int newHeight)
| Resize the image buffer of an existing image to the new dimensions.
void | setChannels (ColorChannels c)
| set color mChannels of this image.
void | setNofChannels (ColorChannels c)
| set color mChannels of this image.
std::size_t | width () const
| Return the mWidth of the picture.
virtual | ~Image ()
| Destroy an Image object and release the image buffer.
## Protected Member Functions
void | updateFromOpencvHeader (const IplImage *image)
| Updates the internal attributes from a given OpenCV header.
void | updateOpencvHeader ()
| Updates the internal mOpenCvHeader attribute.
## Protected Attributes
std::size_t | mAllocatedBytes
| number of allocated bytes in total for this image
std::size_t | mAllocatedHeight
| allocated mHeight for this Image
std::size_t | mAllocatedWidth
| allocated mWidth for this Image in BYTES (usually is aligned to sth)
BitsPerChannel | mBitsPerChannel
| number of bits per mChannels (default 8)
ColorChannels | mChannels
| Color mChannels per pixel.
std::size_t | mHeight
| mHeight of the stored image in pixel (may be smaller than mAllocatedHeight)
unsigned char * | mImageBuffer
| buffer for this image
LineAlignment | mLineAlignment
| Alignment of image lines (default 4).
std::size_t | mNofChannels
| number of mChannels per pixel
IplImage * | mOpenCvHeader
| For compatibility provide an OpenCV Header.
std::size_t | mWidth
| mWidth of the stored image in pixel (may be smaller than mAllocatedWidth and widthStep)

## Detailed Description

Class for Image Storage.

Author:
  Martin Wojtczyk <wojtczyk@in.tum.de>

Image represents an Image and provides converter functions to the OpenCV IplImage data type.

## Member Enumeration Documentation

enum opentl::core::cvdata::Image::BitsPerChannel

Enumerator:

  BPC8U |
  BPC8S |
  BPC16U |
  BPC16S |
  BPC32F |
  BPC32S |
  BPC64F |

enum opentl::core::cvdata::Image::ColorChannels

Enumerator:

  GRAYSCALE |
  BGR |
  RGB |
  RGBA |
  BGRA |
  HSV |
  RGCR |

enum opentl::core::cvdata::Image::LineAlignment

Enumerator:

  A4 |

## Constructor & Destructor Documentation

opentl::core::cvdata::Image::Image | ( | int | initWidth = `1`,
|  | int | initHeight = `1`,
|  | ColorChannels | initChannels = `RGB`,
|  | BitsPerChannel | bpc = `BPC8U` |
| ) |  |  |

Create an Image with the given dimensions and number of mChannels.

Parameters:

  | initWidth | Width of the new image
  | initHeight | Height of the new image
  | initChannels | color mChannels (RGB, BGR, GRAYSCALE, BGRA, RGBA)

opentl::core::cvdata::Image::Image | ( | const IplImage * | image | ) |

Create an Image based on an OpenCV image.

Parameters:

  | image | The OpenCV Source image

opentl::core::cvdata::Image::Image | ( | const Image & | image | ) |

Copy Constructor.

opentl::core::cvdata::Image::Image | ( | std::string | filename | ) |

Create an Image from a file.

Parameters:

  | filename | filename of the image to be loaded

virtual opentl::core::cvdata::Image::~Image | ( |  | ) | `[virtual]`

Destroy an Image object and release the image buffer.

## Member Function Documentation

std::size_t opentl::core::cvdata::Image::allocatedBytes | ( |  | ) | const`[inline]`

Return the number of bytes allocated for this Image.

std::size_t opentl::core::cvdata::Image::allocatedHeight | ( |  | ) | const`[inline]`

This value should be equal to the mHeight of the picture.

std::size_t opentl::core::cvdata::Image::allocatedWidth | ( |  | ) | const`[inline]`

Return the number of bytes for a horizontal picture line.

The allocated mWidth is >= the mWidth of a picture and aligned to the align parameter.

BitsPerChannel opentl::core::cvdata::Image::bitsPerChannel | ( |  | ) | const

Return the number of bits per channel.

void opentl::core::cvdata::Image::blendImage | ( | const Image & | imageToBlend,
|  | CvRect * | pDestArea,
|  | CvRect * | srcArea = `NULL`,
|  | double | dOpacity = `1.0` |
| ) |  |  |

Blends an area of another image over an area of this image

Parameters:

  | imageToBlend | image that should be blended over this image
  | pDestArea | area in this image where to blend the area from imageToBlend. Image part coming from imageToBlend will be automatically rescaled to fit into destArea
  | pSrcArea | area of imageToBlend to blend. To blend the whole imageToBlend, pass NULL
  | dOpacity | which opacity will be used while blending

ColorChannels opentl::core::cvdata::Image::channels | ( |  | ) | const

Return color mChannels of this image.

virtual Image* opentl::core::cvdata::Image::clone | ( |  | ) | const`[virtual]`

void opentl::core::cvdata::Image::dumpIplImage | ( | char * | windowName = `NULL`,
|  | int | delay = `0` |
| ) |  |  | `[inline]`

Dump contents into an OpenCv window, and wait for a pressed key to exit.

Parameters:

  | windowName | If NULL, a new OpenCV window is created, and it stops for pressed key. Else, the window name is used, and the delay value as well (it may stop or not).
  | delay | Time delay before exiting (0 = wait forever until key pressed).

void opentl::core::cvdata::Image::fillZero | ( |  | ) |

Fill image with 0 values.

std::size_t opentl::core::cvdata::Image::height | ( |  | ) | const`[inline]`

Return the mHeight of the picture.

unsigned char* opentl::core::cvdata::Image::imageBuffer | ( |  | ) | const`[inline]`

Return a pointer to the internal image buffer.

IplImage* opentl::core::cvdata::Image::iplImage | ( |  | ) | const`[inline]`

Return a pointer to this image in a form which is compatible with OpenCV.

The memory of the IplImage is released on destruction of this Image ObjModel.

virtual std::size_t opentl::core::cvdata::Image::nofChannels | ( |  | ) | const`[virtual]`

set number of color mChannels of this image.

unsigned char& opentl::core::cvdata::Image::operator() | ( | unsigned | x,
|  | unsigned | y,
|  | unsigned | channel |
| ) |  |  | `[inline]`

Random Pixel Access.

Parameters:

  | x | x-coordinate of the pixel starting at 0
  | y | y-coordinate of the pixel starting at 0
  | channel | Select the desired channel (0, 1, 2 or 3)

This operator doesn't check any bounds, yet. For performance reasons this function was declared inline, but still it involves 2 multiplications. Please do not use this function for sequential pixel access.

Image& opentl::core::cvdata::Image::operator= | ( | const Image & | img | ) |

Random Pixel Access.

Parameters:

  | x | x-coordinate of the pixel starting at 0
  | y | y-coordinate of the pixel starting at 0
  | channel | Select the desired channel (0, 1, 2 or 3)

This operator doesn't check any bounds, yet. For performance reasons this function was declared inline, but still it involves 2 multiplications. Please do not use this function for sequential pixel access.

void opentl::core::cvdata::Image::resizeMemory | ( | const int | newWidth,
|  | const int | newHeight |
| ) |  |  |

Resize the image buffer of an existing image to the new dimensions.

Parameters:

  | newWidth | The new mWidth of the image
  | newHeight | The new mHeight of the image

Release an existing image buffer and allocate a new image buffer for the given dimensions with appropriate pixel line alignment. The content of the new image buffer is undefined.

void opentl::core::cvdata::Image::setChannels | ( | ColorChannels | c | ) |

set color mChannels of this image.

void opentl::core::cvdata::Image::setNofChannels | ( | ColorChannels | c | ) |

set color mChannels of this image.

void opentl::core::cvdata::Image::updateFromOpencvHeader | ( | const IplImage * | image | ) | `[protected]`

Updates the internal attributes from a given OpenCV header.

void opentl::core::cvdata::Image::updateOpencvHeader | ( |  | ) | `[protected]`

Updates the internal mOpenCvHeader attribute.

std::size_t opentl::core::cvdata::Image::width | ( |  | ) | const`[inline]`

Return the mWidth of the picture.

## Member Data Documentation

std::size_t opentl::core::cvdata::Image::mAllocatedBytes`[protected]`

number of allocated bytes in total for this image

std::size_t opentl::core::cvdata::Image::mAllocatedHeight`[protected]`

allocated mHeight for this Image

std::size_t opentl::core::cvdata::Image::mAllocatedWidth`[protected]`

allocated mWidth for this Image in BYTES (usually is aligned to sth)

BitsPerChannel opentl::core::cvdata::Image::mBitsPerChannel`[protected]`

number of bits per mChannels (default 8)

ColorChannels opentl::core::cvdata::Image::mChannels`[protected]`

Color mChannels per pixel.

std::size_t opentl::core::cvdata::Image::mHeight`[protected]`

mHeight of the stored image in pixel (may be smaller than mAllocatedHeight)

unsigned char* opentl::core::cvdata::Image::mImageBuffer`[protected]`

buffer for this image

LineAlignment opentl::core::cvdata::Image::mLineAlignment`[protected]`

Alignment of image lines (default 4).

std::size_t opentl::core::cvdata::Image::mNofChannels`[protected]`

number of mChannels per pixel

IplImage* opentl::core::cvdata::Image::mOpenCvHeader`[protected]`

For compatibility provide an OpenCV Header.

std::size_t opentl::core::cvdata::Image::mWidth`[protected]`

mWidth of the stored image in pixel (may be smaller than mAllocatedWidth and widthStep)