lsseg::Image< T > Class Template Reference

An 1, 2 or 3-dimensional image with an arbitrary number of channels. More...

#include <Image.h>

List of all members.

Public Types

typedef T value_type
 Get the value type of the Image<T> class.

Public Member Functions

 Image ()
 emtpy constructor - makes an image of size 0
 Image (int x, int y, int z=1, int chan=1, T fill_val=0)
 constructor
virtual ~Image ()
 destructor
template<typename U>
 Image (const Image< U > &rhs)
 Constructor converting from different type.
 Image (const Image< T > &rhs)
 copy constructor
template<typename U>
 Image (const Image< U > &rhs, bool copy)
 Quasi-copy constructor, where copying of image contents is optional.
virtual Image< T > & operator= (const Image< T > &rhs)
 assignment operator
Image< T > & operator= (const T &val)
 Fill all pixels of image with a particular value val.
unsigned long int size () const
 get total size (in number of pixels) of an image
unsigned long int channelSize () const
 get size of each channel (in number of pixels) of an image
unsigned long int graySize2D () const
 get size of one x-y slice of one channel of an image (i.e. # pixels in x-dimension multiplied by # pixels in y-dimension)
int dimx () const
 get number of pixels in x-direction
int dimy () const
 get number of pixels in y-direction
int dimz () const
 get number of pixels in z-direction
int numChannels () const
 get number of separate image channels
template<typename U>
void resize (const Image< U > &rhs)
 resize image to the same shape as another image rhs. Previous image content will be destroyed.
virtual void resize (int x, int y, int z=1, int channels=1)
 resize image. Previous image content will be destroyed.
virtual void swap (Image< T > &rhs)
 swapping two images
Image< T > & operator+= (const Image< T > &rhs)
 add another image to this one, pixel-by-pixel
Image< T > & operator-= (const Image< T > &rhs)
 subtract another image from this one, pixel-by-pixel
Image< T > & operator+= (T a)
 add a scalar value to all pixels in the image
Image< T > & operator-= (T a)
 subtract a scalar value from all pixels in the image
Image< T > & operator *= (T a)
 multiply all pixels in the image with a given scalar value.
Image< T > & operator/= (T a)
 divide all pixels in the image with a given scalar value.
max () const
 get the maximum pixel value of the image (over all channels)
min () const
 get the minimum pixel value of the image (over all channels)
template<typename U>
bool spatial_compatible (const Image< U > &rhs) const
 Check if another image is "spatial compatible" with this image.
template<typename U>
bool size_compatible (const Image< U > &rhs) const
 Check if another Image is "size compatible" with this image.
void fill (T val)
 Fill the whole image (all pixels in all channels) with a particular value val.
void setAbsolute ()
 Set all pixels in the image to their absolute value.
getAverage () const
 get the average value of all pixels in the image.
T * begin ()
 get an iterator to the beginning of the image pixel storage array
T * end ()
 get an iterator to the one-past-end of the image pixel storage array
const T * begin () const
 get a const iterator to the beginning of the image pixel storage array
const T * end () const
 get a const iterator to the one-past-end of the image pixel storage array
T * channelBegin (int channel)
 get an iterator to the beginning of where a particular channel is stored in the image pixel storage array.
T * channelEnd (int channel)
 get an iterator to the one-past-end of where a particular channel is stored in the image pixel storage array.
const T * channelBegin (int channel) const
 get a const iterator to the beginning of where a particular channel is stored in the image pixel storage array.
const T * channelEnd (int channel) const
 get a const iterator to the one-past-end of where a particular channel is stored in the image pixel storage array.
void superpose (const Image< T > &img)
 superpose an image img onto this image.
void intersect (const Image< T > &img)
 Intersect another image with *this image.
void dumpInfo (std::ostream &os) const
 dump info about image resolution and number of channels to the stream os. Useful for debug purposes.
size_t indexOf (int x, int y) const
 get the internal storage index of a pixel at position (x, y).
size_t indexOf (int x, int y, int z) const
 get the internal storage index of a pixel at position (x, y, z).
size_t indexOf (int x, int y, int z, int c) const
 get the internal storage index of a pixel at position (x, y, z), and for the channel c.
T & operator() (int x, int y)
 read/write access to the pixel value at position (x, y)
T & operator() (int x, int y, int z)
 read/write access to the pixel value at position (x, y, z).
T & operator() (int x, int y, int z, int c)
 read/write access to the pixel value at position (x, y, z), and for the channel c.
const T & operator() (int x, int y) const
 read-only access to the pixel value at position (x, y)
const T & operator() (int x, int y, int z) const
 read-only access to the pixel value at position (x, y, z).
const T & operator() (int x, int y, int z, int c) const
 read-only access to the pixel value at position (x, y, z), and for the channel c.
T & operator[] (unsigned int ix)
 read/write access to the pixel value at internal storage position ix.
const T & operator[] (unsigned int ix) const
 read-only access to the pixel value at internal storage position ix.
virtual void permute (const int *const perm)
 permute the image's x, y, z and channel indices.
void write (std::ostream &os, bool binary=true) const
 write the Image to a stream, either in ASCII or in binary format.
virtual void read (std::istream &is, bool binary=true)
 read an Image from a stream, either in binary or ASCII format.
void applyMask (const Image< char > &mask)
 mask out parts of the Image by setting the concerned pixel values to 0.
void makeChannelImage (Image< T > &target, int ch)
 make an Image that is a copy of one of the channels of *this image.

Protected Attributes

int dim_ [4]
 stores the size of the x, y and z dimensions, as well as the number of channels.
std::vector< T > data_
 STL vector storing the image pixels.


Detailed Description

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

An 1, 2 or 3-dimensional image with an arbitrary number of channels.

This class represents an 1, 2 or 3-dimensional image with an arbitrary number of channels. It is parametrized on its type, and can thus be used to represent both images with floating point and integer (as well as boolean, i.e. 'mask') values.

Definition at line 76 of file Image.h.


Member Typedef Documentation

template<typename T>
typedef T lsseg::Image< T >::value_type

Get the value type of the Image<T> class.

Definition at line 81 of file Image.h.


Constructor & Destructor Documentation

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

emtpy constructor - makes an image of size 0

Definition at line 84 of file Image.h.

template<typename T>
lsseg::Image< T >::Image ( int  x,
int  y,
int  z = 1,
int  chan = 1,
fill_val = 0 
) [inline]

constructor

Parameters:
x resolution (in # pixels) in x-direction (minimum 1)
y resolution (in # pixels) in y-direction (minimum 1)
z resolution (in # pixels) in z-direction (minimum 1)
chan number of channels in the image (minimum 1)
fill_val which value to fill the pixels with (default is 0)

Definition at line 94 of file Image.h.

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

destructor

Definition at line 104 of file Image.h.

template<typename T>
template<typename U>
lsseg::Image< T >::Image ( const Image< U > &  rhs  )  [inline]

Constructor converting from different type.

Using implicit conversion to convert from the argument Image's value type U to (*this) Image's value type T.

Definition at line 111 of file Image.h.

template<typename T>
lsseg::Image< T >::Image ( const Image< T > &  rhs  )  [inline]

copy constructor

Definition at line 122 of file Image.h.

template<typename T>
template<typename U>
lsseg::Image< T >::Image ( const Image< U > &  rhs,
bool  copy 
) [inline]

Quasi-copy constructor, where copying of image contents is optional.

Can be used when you want to create an Image of the same shape as a previously existing image, but not necessarily with the same type or contents.

Parameters:
rhs the Image to be "copied"
copy if false, only the image shape will be copied; if true, the image contents will be copied as well.

Definition at line 133 of file Image.h.


Member Function Documentation

template<typename T>
void lsseg::Image< T >::applyMask ( const Image< char > &  mask  )  [inline]

mask out parts of the Image by setting the concerned pixel values to 0.

Parameters:
mask The Mask is a (typically one-channeled) image whose pixel values are interpreted as boolean values. Read more about masks here. the mask argument should be spatial_compatible() with this image, and each pixel in this image whose corresponding pixel in mask is false, will be set to zero ("masked out") by applying this function. (If this image is multichanneled and the mask single-channeled, the mask will be applied to each channel separately).
Note: Although Mask s represent boolean values, their pixel value type is char. The reason is that this in our case has proven to be the best choice performance-wise.

Definition at line 601 of file Image.h.

template<typename T>
const T* lsseg::Image< T >::begin (  )  const [inline]

get a const iterator to the beginning of the image pixel storage array

Definition at line 332 of file Image.h.

template<typename T>
T* lsseg::Image< T >::begin (  )  [inline]

get an iterator to the beginning of the image pixel storage array

Definition at line 326 of file Image.h.

template<typename T>
const T* lsseg::Image< T >::channelBegin ( int  channel  )  const [inline]

get a const iterator to the beginning of where a particular channel is stored in the image pixel storage array.

Parameters:
channel the channel whose beginning of storage we want an iterator to

Definition at line 351 of file Image.h.

template<typename T>
T* lsseg::Image< T >::channelBegin ( int  channel  )  [inline]

get an iterator to the beginning of where a particular channel is stored in the image pixel storage array.

Parameters:
channel the channel whose beginning of storage we want an iterator to

Definition at line 341 of file Image.h.

template<typename T>
const T* lsseg::Image< T >::channelEnd ( int  channel  )  const [inline]

get a const iterator to the one-past-end of where a particular channel is stored in the image pixel storage array.

Parameters:
channel the channel whose one-past-end of storage we want an iterator to

Definition at line 356 of file Image.h.

template<typename T>
T* lsseg::Image< T >::channelEnd ( int  channel  )  [inline]

get an iterator to the one-past-end of where a particular channel is stored in the image pixel storage array.

Parameters:
channel the channel whose one-past-end of storage we want an iterator to

Definition at line 346 of file Image.h.

template<typename T>
unsigned long int lsseg::Image< T >::channelSize (  )  const [inline]

get size of each channel (in number of pixels) of an image

Definition at line 164 of file Image.h.

template<typename T>
int lsseg::Image< T >::dimx (  )  const [inline]

get number of pixels in x-direction

Definition at line 171 of file Image.h.

template<typename T>
int lsseg::Image< T >::dimy (  )  const [inline]

get number of pixels in y-direction

Definition at line 174 of file Image.h.

template<typename T>
int lsseg::Image< T >::dimz (  )  const [inline]

get number of pixels in z-direction

Definition at line 177 of file Image.h.

template<typename T>
void lsseg::Image< T >::dumpInfo ( std::ostream &  os  )  const [inline]

dump info about image resolution and number of channels to the stream os. Useful for debug purposes.

Definition at line 395 of file Image.h.

template<typename T>
const T* lsseg::Image< T >::end (  )  const [inline]

get a const iterator to the one-past-end of the image pixel storage array

Definition at line 335 of file Image.h.

template<typename T>
T* lsseg::Image< T >::end (  )  [inline]

get an iterator to the one-past-end of the image pixel storage array

Definition at line 329 of file Image.h.

template<typename T>
void lsseg::Image< T >::fill ( val  )  [inline]

Fill the whole image (all pixels in all channels) with a particular value val.

Definition at line 312 of file Image.h.

template<typename T>
T lsseg::Image< T >::getAverage (  )  const [inline]

get the average value of all pixels in the image.

Definition at line 322 of file Image.h.

template<typename T>
unsigned long int lsseg::Image< T >::graySize2D (  )  const [inline]

get size of one x-y slice of one channel of an image (i.e. # pixels in x-dimension multiplied by # pixels in y-dimension)

Definition at line 168 of file Image.h.

template<typename T>
size_t lsseg::Image< T >::indexOf ( int  x,
int  y,
int  z,
int  c 
) const [inline]

get the internal storage index of a pixel at position (x, y, z), and for the channel c.

Definition at line 424 of file Image.h.

template<typename T>
size_t lsseg::Image< T >::indexOf ( int  x,
int  y,
int  z 
) const [inline]

get the internal storage index of a pixel at position (x, y, z).

The channel number will be 0. Overloading is not used here for performance reasons.

Definition at line 416 of file Image.h.

template<typename T>
size_t lsseg::Image< T >::indexOf ( int  x,
int  y 
) const [inline]

get the internal storage index of a pixel at position (x, y).

The z position will be 0 and the channel will be 0. Overloading is not used here for performance reasons.

Definition at line 407 of file Image.h.

template<typename T>
void lsseg::Image< T >::intersect ( const Image< T > &  img  )  [inline]

Intersect another image with *this image.

The argument image img must be size_compatible with *this image. The intersection operator && will then be applied to each pixel in this image with its equivalent in the argument image img.

Parameters:
img the image that will intersect with *this image. It should be size_compatible with this image.

Definition at line 388 of file Image.h.

template<typename T>
void lsseg::Image< T >::makeChannelImage ( Image< T > &  target,
int  ch 
) [inline]

make an Image that is a copy of one of the channels of *this image.

Parameters:
target this is the image that will become a copy of a channel of *this image.
ch the channel number in question.

Definition at line 616 of file Image.h.

template<typename T>
T lsseg::Image< T >::max (  )  const [inline]

get the maximum pixel value of the image (over all channels)

Definition at line 280 of file Image.h.

template<typename T>
T lsseg::Image< T >::min (  )  const [inline]

get the minimum pixel value of the image (over all channels)

Definition at line 283 of file Image.h.

template<typename T>
int lsseg::Image< T >::numChannels (  )  const [inline]

get number of separate image channels

Definition at line 180 of file Image.h.

template<typename T>
Image<T>& lsseg::Image< T >::operator *= ( a  )  [inline]

multiply all pixels in the image with a given scalar value.

Parameters:
a the scalar value that all pixels in the image will be multiplied with, regardless of channel.

Definition at line 262 of file Image.h.

template<typename T>
const T& lsseg::Image< T >::operator() ( int  x,
int  y,
int  z,
int  c 
) const [inline]

read-only access to the pixel value at position (x, y, z), and for the channel c.

Definition at line 458 of file Image.h.

template<typename T>
const T& lsseg::Image< T >::operator() ( int  x,
int  y,
int  z 
) const [inline]

read-only access to the pixel value at position (x, y, z).

The channel number will be 0. Overloading is not used here for performance reasons.

Definition at line 454 of file Image.h.

template<typename T>
const T& lsseg::Image< T >::operator() ( int  x,
int  y 
) const [inline]

read-only access to the pixel value at position (x, y)

The z position will be 0 and the channel will be 0. Overloading is not used here for performance reasons.

Definition at line 449 of file Image.h.

template<typename T>
T& lsseg::Image< T >::operator() ( int  x,
int  y,
int  z,
int  c 
) [inline]

read/write access to the pixel value at position (x, y, z), and for the channel c.

Definition at line 443 of file Image.h.

template<typename T>
T& lsseg::Image< T >::operator() ( int  x,
int  y,
int  z 
) [inline]

read/write access to the pixel value at position (x, y, z).

The channel number will be 0. Overloading is not used here for performance reasons.

Definition at line 439 of file Image.h.

template<typename T>
T& lsseg::Image< T >::operator() ( int  x,
int  y 
) [inline]

read/write access to the pixel value at position (x, y)

The z position will be 0 and the channel will be 0. Overloading is not used here for performance reasons.

Definition at line 434 of file Image.h.

template<typename T>
Image<T>& lsseg::Image< T >::operator+= ( a  )  [inline]

add a scalar value to all pixels in the image

Parameters:
a a scalar value which will be added to all pixels in the image, regardless of channel.

Definition at line 242 of file Image.h.

template<typename T>
Image<T>& lsseg::Image< T >::operator+= ( const Image< T > &  rhs  )  [inline]

add another image to this one, pixel-by-pixel

The Image added must be parametrized on the same type and be size_compatible.

Definition at line 214 of file Image.h.

template<typename T>
Image<T>& lsseg::Image< T >::operator-= ( a  )  [inline]

subtract a scalar value from all pixels in the image

Parameters:
a a scalar value which will be subtracted from all pixels in the image, regardless of channel.

Definition at line 254 of file Image.h.

template<typename T>
Image<T>& lsseg::Image< T >::operator-= ( const Image< T > &  rhs  )  [inline]

subtract another image from this one, pixel-by-pixel

The Image added must be parametrized on the same type and be size_compatible.

Definition at line 228 of file Image.h.

template<typename T>
Image<T>& lsseg::Image< T >::operator/= ( a  )  [inline]

divide all pixels in the image with a given scalar value.

Parameters:
a the scalar value that all pixels in the image will be divided with, regardless of channel.

Definition at line 274 of file Image.h.

template<typename T>
Image<T>& lsseg::Image< T >::operator= ( const T &  val  )  [inline]

Fill all pixels of image with a particular value val.

Reimplemented in lsseg::LevelSetFunction.

Definition at line 155 of file Image.h.

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

assignment operator

Reimplemented in lsseg::LevelSetFunction.

Definition at line 148 of file Image.h.

template<typename T>
const T& lsseg::Image< T >::operator[] ( unsigned int  ix  )  const [inline]

read-only access to the pixel value at internal storage position ix.

The internal storage position can be found using the indexOf() function.

Definition at line 470 of file Image.h.

template<typename T>
T& lsseg::Image< T >::operator[] ( unsigned int  ix  )  [inline]

read/write access to the pixel value at internal storage position ix.

The internal storage position can be found using the indexOf() function.

Definition at line 463 of file Image.h.

template<typename T>
virtual void lsseg::Image< T >::permute ( const int *const   perm  )  [inline, virtual]

permute the image's x, y, z and channel indices.

Parameters:
perm pointer to an integer array of 4 elements, specifying the permutation to be carried out. The integer array should contain a permutation of the four numbers 0, 1, 2 and 3. If we assign these numbers to the image indices x, y, z and channel respectively, this array specifies how the indices will be rearranged. The value at perm[i] specifies which of the indices in the image before mutation will be repositioned to index i after permutation.

Reimplemented in lsseg::LevelSetFunction.

Definition at line 483 of file Image.h.

template<typename T>
virtual void lsseg::Image< T >::read ( std::istream &  is,
bool  binary = true 
) [inline, virtual]

read an Image from a stream, either in binary or ASCII format.

Parameters:
is the stream from which the Image will be read
binary set this argument to true to read from a binary stream, false to read from an ASCII text stream.

Reimplemented in lsseg::LevelSetFunction.

Definition at line 551 of file Image.h.

template<typename T>
virtual void lsseg::Image< T >::resize ( int  x,
int  y,
int  z = 1,
int  channels = 1 
) [inline, virtual]

resize image. Previous image content will be destroyed.

Parameters:
x new resolution in x-direction
y new resolution in y-direction
z new resolution in z-direction
channels new number of image channels

Reimplemented in lsseg::LevelSetFunction.

Definition at line 195 of file Image.h.

template<typename T>
template<typename U>
void lsseg::Image< T >::resize ( const Image< U > &  rhs  )  [inline]

resize image to the same shape as another image rhs. Previous image content will be destroyed.

Definition at line 185 of file Image.h.

template<typename T>
void lsseg::Image< T >::setAbsolute (  )  [inline]

Set all pixels in the image to their absolute value.

Definition at line 315 of file Image.h.

template<typename T>
unsigned long int lsseg::Image< T >::size (  )  const [inline]

get total size (in number of pixels) of an image

Definition at line 161 of file Image.h.

template<typename T>
template<typename U>
bool lsseg::Image< T >::size_compatible ( const Image< U > &  rhs  )  const [inline]

Check if another Image is "size compatible" with this image.

Two images are size compatible if they have the same resolutions in x, y and z, and the same number of channels.

Definition at line 304 of file Image.h.

template<typename T>
template<typename U>
bool lsseg::Image< T >::spatial_compatible ( const Image< U > &  rhs  )  const [inline]

Check if another image is "spatial compatible" with this image.

Two images are spatially compatible if they have the same resolutions in x, y and z. They do not need to have the same number of channels.

Definition at line 291 of file Image.h.

template<typename T>
void lsseg::Image< T >::superpose ( const Image< T > &  img  )  [inline]

superpose an image img onto this image.

The difference between the superpose() function and the operator+= is that the superpose() function does not require the two images to be size_compatible, only that they have the same number of pixels in (at least) the x and y direction, and that the number of channels and z-resolution in *this image is either equal to, or exact multiples of the number of channels and z-resolution in the argument image img. The image img will then be superposed to *this image such that it is repeated along the z-resolution and number of channels.

Parameters:
img the image that will be superposed onto this image. It should have the same resolution in the x and y directions as *this image, and that the z-resolution of *this image is an exact multiple of the z-resolution of img. The same goes for the number of channels.

Definition at line 371 of file Image.h.

template<typename T>
virtual void lsseg::Image< T >::swap ( Image< T > &  rhs  )  [inline, virtual]

swapping two images

Reimplemented in lsseg::LevelSetFunction.

Definition at line 205 of file Image.h.

template<typename T>
void lsseg::Image< T >::write ( std::ostream &  os,
bool  binary = true 
) const [inline]

write the Image to a stream, either in ASCII or in binary format.

Parameters:
os the stream onto which the Image information will be written
binary set this to false to write in ASCII, true to write in binary format.

Definition at line 515 of file Image.h.


Member Data Documentation

template<typename T>
std::vector<T> lsseg::Image< T >::data_ [protected]

STL vector storing the image pixels.

Definition at line 629 of file Image.h.

template<typename T>
int lsseg::Image< T >::dim_[4] [protected]

stores the size of the x, y and z dimensions, as well as the number of channels.

Definition at line 626 of file Image.h.


The documentation for this class was generated from the following file:
Generated on Tue Nov 28 18:35:47 2006 for lsseg by  doxygen 1.4.7