#include <Image.h>
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. | |
T | max () const |
get the maximum pixel value of the image (over all channels) | |
T | 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. | |
T | 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. |
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.
typedef T lsseg::Image< T >::value_type |
lsseg::Image< T >::Image | ( | ) | [inline] |
lsseg::Image< T >::Image | ( | int | x, | |
int | y, | |||
int | z = 1 , |
|||
int | chan = 1 , |
|||
T | fill_val = 0 | |||
) | [inline] |
constructor
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) |
virtual lsseg::Image< T >::~Image | ( | ) | [inline, virtual] |
lsseg::Image< T >::Image | ( | const Image< U > & | rhs | ) | [inline] |
lsseg::Image< T >::Image | ( | const Image< T > & | rhs | ) | [inline] |
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.
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. |
void lsseg::Image< T >::applyMask | ( | const Image< char > & | mask | ) | [inline] |
mask out parts of the Image by setting the concerned pixel values to 0.
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. |
const T* lsseg::Image< T >::begin | ( | ) | const [inline] |
T* lsseg::Image< T >::begin | ( | ) | [inline] |
const T* lsseg::Image< T >::channelBegin | ( | int | channel | ) | const [inline] |
T* lsseg::Image< T >::channelBegin | ( | int | channel | ) | [inline] |
const T* lsseg::Image< T >::channelEnd | ( | int | channel | ) | const [inline] |
T* lsseg::Image< T >::channelEnd | ( | int | channel | ) | [inline] |
unsigned long int lsseg::Image< T >::channelSize | ( | ) | const [inline] |
int lsseg::Image< T >::dimx | ( | ) | const [inline] |
int lsseg::Image< T >::dimy | ( | ) | const [inline] |
int lsseg::Image< T >::dimz | ( | ) | const [inline] |
void lsseg::Image< T >::dumpInfo | ( | std::ostream & | os | ) | const [inline] |
const T* lsseg::Image< T >::end | ( | ) | const [inline] |
T* lsseg::Image< T >::end | ( | ) | [inline] |
void lsseg::Image< T >::fill | ( | T | val | ) | [inline] |
T lsseg::Image< T >::getAverage | ( | ) | const [inline] |
unsigned long int lsseg::Image< T >::graySize2D | ( | ) | const [inline] |
size_t lsseg::Image< T >::indexOf | ( | int | x, | |
int | y, | |||
int | z, | |||
int | c | |||
) | const [inline] |
size_t lsseg::Image< T >::indexOf | ( | int | x, | |
int | y, | |||
int | z | |||
) | const [inline] |
size_t lsseg::Image< T >::indexOf | ( | int | x, | |
int | y | |||
) | const [inline] |
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
.
img | the image that will intersect with *this image. It should be size_compatible with this image. |
void lsseg::Image< T >::makeChannelImage | ( | Image< T > & | target, | |
int | ch | |||
) | [inline] |
T lsseg::Image< T >::max | ( | ) | const [inline] |
T lsseg::Image< T >::min | ( | ) | const [inline] |
int lsseg::Image< T >::numChannels | ( | ) | const [inline] |
Image<T>& lsseg::Image< T >::operator *= | ( | T | a | ) | [inline] |
const T& lsseg::Image< T >::operator() | ( | int | x, | |
int | y, | |||
int | z, | |||
int | c | |||
) | const [inline] |
const T& lsseg::Image< T >::operator() | ( | int | x, | |
int | y, | |||
int | z | |||
) | const [inline] |
const T& lsseg::Image< T >::operator() | ( | int | x, | |
int | y | |||
) | const [inline] |
T& lsseg::Image< T >::operator() | ( | int | x, | |
int | y, | |||
int | z, | |||
int | c | |||
) | [inline] |
T& lsseg::Image< T >::operator() | ( | int | x, | |
int | y, | |||
int | z | |||
) | [inline] |
T& lsseg::Image< T >::operator() | ( | int | x, | |
int | y | |||
) | [inline] |
Image<T>& lsseg::Image< T >::operator+= | ( | T | a | ) | [inline] |
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.
Image<T>& lsseg::Image< T >::operator-= | ( | T | a | ) | [inline] |
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.
Image<T>& lsseg::Image< T >::operator/= | ( | T | a | ) | [inline] |
Image<T>& lsseg::Image< T >::operator= | ( | const T & | val | ) | [inline] |
virtual Image<T>& lsseg::Image< T >::operator= | ( | const Image< T > & | rhs | ) | [inline, virtual] |
const T& lsseg::Image< T >::operator[] | ( | unsigned int | ix | ) | const [inline] |
T& lsseg::Image< T >::operator[] | ( | unsigned int | ix | ) | [inline] |
virtual void lsseg::Image< T >::permute | ( | const int *const | perm | ) | [inline, virtual] |
permute the image's x
, y
, z
and channel indices.
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.
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.
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.
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.
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.
void lsseg::Image< T >::resize | ( | const Image< U > & | rhs | ) | [inline] |
void lsseg::Image< T >::setAbsolute | ( | ) | [inline] |
unsigned long int lsseg::Image< T >::size | ( | ) | const [inline] |
bool lsseg::Image< T >::size_compatible | ( | const Image< U > & | rhs | ) | const [inline] |
bool lsseg::Image< T >::spatial_compatible | ( | const Image< U > & | rhs | ) | const [inline] |
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.
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. |
virtual void lsseg::Image< T >::swap | ( | Image< T > & | rhs | ) | [inline, virtual] |
void lsseg::Image< T >::write | ( | std::ostream & | os, | |
bool | binary = true | |||
) | const [inline] |
std::vector<T> lsseg::Image< T >::data_ [protected] |
int lsseg::Image< T >::dim_[4] [protected] |