kn::Image< T > Class Template Reference

Container for images This class represent any generic image for any size, and basic type and any nb channel. More...

#include <Image.hpp>

Collaboration diagram for kn::Image< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Image ()
 Constructor to build a 0 size image.
 Image (const size_t width, const size_t height, const size_t nbChannel, T *buffer=0)
 Constructor to build an allocated empty image or an image from a raw data buffer.
 Image (const Image< T > &i)
 Copy Constructor.
virtual ~Image ()
 dealoccates image data
virtual T * begin () const
 getting the raw data of the image
virtual T * end () const
 getting the end of raw data of the image
virtual size_t width () const
 getting the width of the image
virtual size_t height () const
 getting the height of the image
virtual size_t nbChannel () const
 getting the number of channel of the image
virtual size_t size () const
 getting the total size of the image
virtual T * operator() (const unsigned int x, const unsigned int y) const
 get pointer on the asked pixel
virtual T * at (const unsigned int x, const unsigned int y) const
 get pointer on the asked pixel (with bounds checking).
virtual T & operator() (const unsigned int x, const unsigned int y, const unsigned int d)
 get component value of the asked pixel
virtual T & at (const unsigned int x, const unsigned int y, const unsigned int d)
 get component value of the asked pixel (with bounds checking).
virtual const T & operator() (const unsigned int x, const unsigned int y, const unsigned int d) const
 get component value of the asked pixel
virtual const T & at (const unsigned int x, const unsigned int y, const unsigned int d) const
 get component value of the asked pixel (with bounds checking) This function behaves the same than the operator() but checks if indices are valid respect to the size of
virtual Image< T > & operator= (const Image &i)
 copy on this image the content of another if they have the same resolution and number of channel; if the calling image have width = height = 0, this function create the adequat memory, else throws an exception.
void fill (const T &value)
 fill all the pixels component to the parameter value
void flip ()
 flip the image vertically
void flop ()
 flop the image horizontally
void rotate ()
 rotate the image by PI/2
void rotateInverse ()
 rotate the image by -PI/2
void getSubImage (unsigned int x, unsigned int y, Image< T > &sub) const
 Get a sub part of the image.
void setSubImage (unsigned int x, unsigned int y, const Image< T > &sub)
 Set a sub part of the image.

Protected Member Functions

void initRows ()
 allocate and initialize the rows array

Protected Attributes

T * data
 raw data of the image
T ** rows
 pointers on each row of the image on the raw date
T * begin_
 pointer on the begining of raw data
T * end_
 pointer on the end of raw data
size_t imageWidth
 width of the image
size_t imageHeight
 height of the image
size_t imageNbChannel
 nb channel of the image
size_t imageSize
 Total size of the image (w*h*d).

Friends

int kn::loadPPM (Image< unsigned char > &res, const std::string &filename)
 Friend function for PPM file format loader.
int kn::loadTGA (Image< unsigned char > &res, const std::string &filename)
 Friend function for TGA file format loader.
int kn::loadJPG (Image< unsigned char > &res, const std::string &filename)
 Friend function for JPG file format loader.
int kn::loadHDR (Image< float > &res, const std::string &filename)
 Friend function for HDR file format loader.


Detailed Description

template<typename T>
class kn::Image< T >

Container for images This class represent any generic image for any size, and basic type and any nb channel.

The data of the image is represented as a unidimensionnal array of the basic typename. Moreover, we store the position of any row allowing a fast acces to any pixel of the image. The first row is the top row and each row is stored from left to right.

Definition at line 63 of file Image.hpp.


Constructor & Destructor Documentation

template<typename T >
kn::Image< T >::Image (  )  [inline]

Constructor to build a 0 size image.

Definition at line 375 of file Image.hpp.

template<typename T>
kn::Image< T >::Image ( const size_t  width,
const size_t  height,
const size_t  nbChannel,
T *  buffer = 0 
) [inline]

Constructor to build an allocated empty image or an image from a raw data buffer.

Parameters:
width width of the image
height height of the image
nbChannel depth of the image
buffer optional data buffer WHICH IS NOT COPYIED

Definition at line 389 of file Image.hpp.

template<typename T>
kn::Image< T >::Image ( const Image< T > &  i  )  [inline]

Copy Constructor.

Parameters:
i Image to clone

Definition at line 410 of file Image.hpp.

template<typename T >
kn::Image< T >::~Image (  )  [inline, virtual]

dealoccates image data

Definition at line 427 of file Image.hpp.


Member Function Documentation

template<typename T>
virtual const T& kn::Image< T >::at ( const unsigned int  x,
const unsigned int  y,
const unsigned int  d 
) const [inline, virtual]

get component value of the asked pixel (with bounds checking) This function behaves the same than the operator() but checks if indices are valid respect to the size of

Parameters:
x width position of the pixel
y height position of the pixel
d component number
Returns:
a value of the component

Definition at line 249 of file Image.hpp.

template<typename T>
virtual T& kn::Image< T >::at ( const unsigned int  x,
const unsigned int  y,
const unsigned int  d 
) [inline, virtual]

get component value of the asked pixel (with bounds checking).

Parameters:
x width position of the pixel
y height position of the pixel
d component number
Returns:
a value of the component

Definition at line 223 of file Image.hpp.

template<typename T>
virtual T* kn::Image< T >::at ( const unsigned int  x,
const unsigned int  y 
) const [inline, virtual]

get pointer on the asked pixel (with bounds checking).

This function is the same than the operator() but checks if indices are valid.

Parameters:
x width position of the pixel
y height position of the pixel
Returns:
a buffer with the pixel

Definition at line 199 of file Image.hpp.

template<typename T>
virtual T* kn::Image< T >::begin (  )  const [inline, virtual]

getting the raw data of the image

Returns:
raw data of the image

Definition at line 140 of file Image.hpp.

template<typename T>
virtual T* kn::Image< T >::end (  )  const [inline, virtual]

getting the end of raw data of the image

Returns:
end of raw data of the image

Definition at line 145 of file Image.hpp.

template<typename T>
void kn::Image< T >::fill ( const T &  value  )  [inline]

fill all the pixels component to the parameter value

Parameters:
value : value used to fill the image

Definition at line 269 of file Image.hpp.

template<typename T>
void kn::Image< T >::flip (  )  [inline]

flip the image vertically

Definition at line 276 of file Image.hpp.

template<typename T>
void kn::Image< T >::flop (  )  [inline]

flop the image horizontally

Definition at line 283 of file Image.hpp.

template<typename T>
void kn::Image< T >::getSubImage ( unsigned int  x,
unsigned int  y,
Image< T > &  sub 
) const [inline]

Get a sub part of the image.

The sub part need to be contained in the image,, else function throws an exception.

Parameters:
x the x-coordinate of the top left corner of sub part
y the y-coordinate of the top left corner of sub part
sub the image which will store the sub part the dimensions of sub are the one of the sub part

Definition at line 537 of file Image.hpp.

template<typename T>
virtual size_t kn::Image< T >::height (  )  const [inline, virtual]

getting the height of the image

Returns:
the height of the image

Definition at line 172 of file Image.hpp.

template<typename T >
void kn::Image< T >::initRows (  )  [inline, protected]

allocate and initialize the rows array

Definition at line 432 of file Image.hpp.

template<typename T>
virtual size_t kn::Image< T >::nbChannel (  )  const [inline, virtual]

getting the number of channel of the image

Returns:
the number of channel of the image

Definition at line 177 of file Image.hpp.

template<typename T>
virtual const T& kn::Image< T >::operator() ( const unsigned int  x,
const unsigned int  y,
const unsigned int  d 
) const [inline, virtual]

get component value of the asked pixel

Parameters:
x width position of the pixel
y height position of the pixel
d component number
Returns:
a value of the component

Definition at line 237 of file Image.hpp.

template<typename T>
virtual T& kn::Image< T >::operator() ( const unsigned int  x,
const unsigned int  y,
const unsigned int  d 
) [inline, virtual]

get component value of the asked pixel

Parameters:
x width position of the pixel
y height position of the pixel
d component number
Returns:
a value of the component

Definition at line 213 of file Image.hpp.

template<typename T>
virtual T* kn::Image< T >::operator() ( const unsigned int  x,
const unsigned int  y 
) const [inline, virtual]

get pointer on the asked pixel

Parameters:
x width position of the pixel
y height position of the pixel
Returns:
a buffer with the pixel

Definition at line 189 of file Image.hpp.

template<typename T >
Image< T > & kn::Image< T >::operator= ( const Image< T > &  i  )  [inline, virtual]

copy on this image the content of another if they have the same resolution and number of channel; if the calling image have width = height = 0, this function create the adequat memory, else throws an exception.

Parameters:
i : source image
Exceptions:
ImageException : incompatible image size
Returns:
a reference to the destination image

Definition at line 516 of file Image.hpp.

template<typename T>
void kn::Image< T >::rotate (  )  [inline]

rotate the image by PI/2

Definition at line 292 of file Image.hpp.

template<typename T>
void kn::Image< T >::rotateInverse (  )  [inline]

rotate the image by -PI/2

Definition at line 305 of file Image.hpp.

template<typename T>
void kn::Image< T >::setSubImage ( unsigned int  x,
unsigned int  y,
const Image< T > &  sub 
) [inline]

Set a sub part of the image.

The sub part need to be contained in the image,, else function throws an exception.

Parameters:
x the x-coordinate of the top left corner of sub part
y the y-coordinate of the top left corner of sub part
sub the image which contains the sub part the dimensions of sub are the one of the sub part

Definition at line 550 of file Image.hpp.

template<typename T>
virtual size_t kn::Image< T >::size (  )  const [inline, virtual]

getting the total size of the image

Returns:
the total of the image

Definition at line 182 of file Image.hpp.

template<typename T>
virtual size_t kn::Image< T >::width (  )  const [inline, virtual]

getting the width of the image

Returns:
the width of the image

Definition at line 167 of file Image.hpp.


Friends And Related Function Documentation

template<typename T>
int kn::loadHDR ( Image< float > &  res,
const std::string &  filename 
) [friend]

Friend function for HDR file format loader.

Parameters:
res image receiving data
filename filename containing data
Returns:
0 if succeeds / -1 if fails

template<typename T>
int kn::loadJPG ( Image< unsigned char > &  res,
const std::string &  filename 
) [friend]

Friend function for JPG file format loader.

Parameters:
res image receiving data
filename filename containing data
Returns:
The type of the JPG file (see kn::JPG_file_type)

template<typename T>
int kn::loadPPM ( Image< unsigned char > &  res,
const std::string &  filename 
) [friend]

Friend function for PPM file format loader.

Parameters:
res image receiving data
filename filename containing data
Returns:
nb_channel of image (depending on format P1,P2,P3,P4,P5 or P6)

template<typename T>
int kn::loadTGA ( Image< unsigned char > &  res,
const std::string &  filename 
) [friend]

Friend function for TGA file format loader.

Parameters:
res image receiving data
filename filename containing data
Returns:
The type of the TGA file (see kn::TGA_file_type)


Member Data Documentation

template<typename T>
T* kn::Image< T >::begin_ [protected]

pointer on the begining of raw data

Definition at line 130 of file Image.hpp.

template<typename T>
T* kn::Image< T >::data [protected]

raw data of the image

Definition at line 118 of file Image.hpp.

template<typename T>
T* kn::Image< T >::end_ [protected]

pointer on the end of raw data

Definition at line 134 of file Image.hpp.

template<typename T>
size_t kn::Image< T >::imageHeight [protected]

height of the image

Definition at line 154 of file Image.hpp.

template<typename T>
size_t kn::Image< T >::imageNbChannel [protected]

nb channel of the image

Definition at line 158 of file Image.hpp.

template<typename T>
size_t kn::Image< T >::imageSize [protected]

Total size of the image (w*h*d).

Definition at line 162 of file Image.hpp.

template<typename T>
size_t kn::Image< T >::imageWidth [protected]

width of the image

Definition at line 150 of file Image.hpp.

template<typename T>
T** kn::Image< T >::rows [protected]

pointers on each row of the image on the raw date

Definition at line 122 of file Image.hpp.


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

Generated on Thu Nov 12 16:06:36 2009 for OpenKraken-image by  doxygen 1.5.8