In file inrimage/BaseInrimage.h:

class BaseInrimage

Base class for inrimages

Inheritance:


Public Methods

unsigned int getX () const
get image x dimension
unsigned int getY () const
get image y dimension
unsigned int getZ () const
get image z dimension
void setX (const unsigned int x)
set image x dimension
void setY (const unsigned int y)
set image y dimension
void setZ (const unsigned int z)
set image z dimension
void setVdim (const unsigned int v)
set image vectorial dimension
unsigned int getVdim (void) const
get image vectorial dimension
unsigned int getWdim (void) const
get image words size (in bytes)
float getVX () const
get image voxel size in x dimension
float getVY () const
get image voxel size in y dimension
float getVZ () const
get image voxel size in z dimension
void* getData () const
get image data buffer
unsigned int getWordSize () const
get image word size
WORD_KIND getWordKind () const
get word kind
SIGN getWordSign () const
get word sign
VECTORIAL_MODE getVectorialMode () const
get VECTORIAL_MODE
IMAGE_FORMAT getFileFormat (void) const
get image file format
void setFileFormat (IMAGE_FORMAT f)
set a new image file format for saving
void write (const char *name) const throw(UnableToCreateFile, UnableToWriteHeader, UnableToWriteData)
Writes inrimage to file whose path is given as argument
BaseInrimage& operator= (const BaseInrimage& img) throw(InvalidSize, InvalidVectorialMode, InvalidVoxelSize, NotEnoughMemory)
Makes *this an replica of img
virtual void allocate (void) throw(NotEnoughMemory)
Allocates and fills with zero image data buffer
virtual void free (void)
frees image data buffer
void setVoxelSize (float vx, float vy, float vz) throw(InvalidVoxelSize)
set a new image voxel size
virtual void* setData (void *data)
set a new data buffer
virtual void setVectorialMode (VECTORIAL_MODE vm) throw(InvalidVectorialMode)
Changes image vectorial mode
virtual void setInterlacedData (void)
toggles buffer to produce an interlaced vector image (for vectorial images only)
virtual void setNonInterlacedData (void)
toggles buffer to produce an interlaced vector image (for vectorial images only)
void setUserParams (unsigned int n, char **params)
set user defined parameters strings to write into image file header
virtual void resize (unsigned int xdim, unsigned int ydim, unsigned int zdim, unsigned int vdim = 1, unsigned int wdim = 1, WORD_KIND wordKind = WK_FIXED, SIGN sign = SGN_SIGNED) throw(InvalidSize, NotEnoughMemory)
Changes image size
virtual void setWords (WORD_KIND wordKind = WK_FIXED, SIGN sign = SGN_SIGNED) throw(NotEnoughMemory)
Changes image word type
static BaseInrimage* _image2BaseInrimage (const _image& img) throw(BaseInrimage::InvalidSize, BaseInrimage::InvalidVoxelSize, BaseInrimage::InvalidVectorialMode)
Converts an _image structure to a BaseInrimage
static _image* BaseInrimage2_image (const BaseInrimage& bimg)
Converts a BaseImage structure to an _image
bool userField (const char *name, char *val, unsigned int n) const
Check whether given field exists in user defined strings
bool updateUserField (const char *name, const char *val) const
Check whether given field exists in user defined strings
void addUserField (const char *name, const char *val)
Add a given field to the user defined strings
bool removeUserField (const char *name)
Remove a given field to the user defined strings
template void rescaleBuffer (FROM, TO, double fmin, double fmax, double tmin, double tmax, double offset, BaseInrimage& img)
Rescale data values into another image
void getBounds (double &min, double &max) const
compute grey level bounds of image buffer (valid for image scalar types only)

Public

Exception classes
class ImageNotFound : public Exception
image file was not found
class UnknownImageType : public Exception
unknown image file format
class InvalidHeader : public Exception
invalid inrimage header
class InvalidData : public Exception
invalid inrimage data
class UnableToCreateFile : public Exception
unable to create file for writting
class UnableToWriteHeader : public Exception
unable to write image header in file
class UnableToWriteData : public Exception
unable to write image data in file
class NotEnoughMemory : public Exception
unable to allocate memory
class InvalidSize : public Exception
image size cannot be 0 or negative
class InvalidVoxelSize : public Exception
voxel size cannot be 0 or negative
class InvalidVectorialMode : public Exception
attempt to set vectorial mode to a scalar image or opposite
Constructors
BaseInrimage (const char *name, bool headerOnly = false, VECTORIAL_MODE vm = VM_INTERLACED, VECTORIAL_MODE filevm = VM_INTERLACED) throw(ImageNotFound, UnknownImageType, InvalidHeader, InvalidData)
Reads inrimage from file whose path is given as argument
BaseInrimage (unsigned int xdim, unsigned int ydim, unsigned int zdim, unsigned int vdim = 1, unsigned int wdim = 1, WORD_KIND wordKind = WK_FIXED, SIGN sign = SGN_SIGNED, float vx = 1.0, float vy = 1.0, float vz = 1.0) throw(InvalidSize, NotEnoughMemory, InvalidVoxelSize)
Creates an inrimage with given size and word type
BaseInrimage (unsigned int xdim, unsigned int ydim, unsigned int zdim, void *data, unsigned int vdim = 1, unsigned int wdim = 1, WORD_KIND wordKind = WK_FIXED, SIGN sign = SGN_SIGNED, float vx = 1.0, float vy = 1.0, float vz = 1.0) throw(InvalidSize, InvalidVoxelSize)
Creates an inrimage with given size and word type
explicit BaseInrimage (const BaseInrimage& img) throw(InvalidSize, InvalidVectorialMode, InvalidVoxelSize, NotEnoughMemory)
creates an replica of img
Destructors
virtual ~BaseInrimage ()
frees image buffer

Protected Fields

unsigned int xdim
Image x dimension (number of columns)
unsigned int ydim
Image y dimension (number of rows)
unsigned int zdim
Image z dimension (number of planes)
unsigned int vdim
Image vectorial dimension
float vx
Image voxel size in x dimension
float vy
Image voxel size in y dimension
float vz
Image voxel size in z dimension
void* data
Image data buffer
unsigned int wdim
Image word size (in bytes)
WORD_KIND wordKind
Image word kind
SIGN sign
Image word sign
VECTORIAL_MODE vectMode
Data buffer vectors are interlaced or non interlaced
char** user
User defined strings array
unsigned int nuser
Number of user strings
IMAGE_FORMAT imageFormat
format of image source file
ImageInformation* info
Optional additional information

Private Methods

_image* readHeader (const char *name) throw(ImageNotFound, InvalidHeader, UnknownImageType)
open inrimage file and read header

Documentation

Base class for inrimages
Exception classes

class ImageNotFound: public Exception
image file was not found

class UnknownImageType: public Exception
unknown image file format

class InvalidHeader: public Exception
invalid inrimage header

class InvalidData: public Exception
invalid inrimage data

class UnableToCreateFile: public Exception
unable to create file for writting

class UnableToWriteHeader: public Exception
unable to write image header in file

class UnableToWriteData: public Exception
unable to write image data in file

class NotEnoughMemory: public Exception
unable to allocate memory

class InvalidSize: public Exception
image size cannot be 0 or negative

class InvalidVoxelSize: public Exception
voxel size cannot be 0 or negative

class InvalidVectorialMode: public Exception
attempt to set vectorial mode to a scalar image or opposite

unsigned int xdim
Image x dimension (number of columns)

unsigned int ydim
Image y dimension (number of rows)

unsigned int zdim
Image z dimension (number of planes)

unsigned int vdim
Image vectorial dimension

float vx
Image voxel size in x dimension

float vy
Image voxel size in y dimension

float vz
Image voxel size in z dimension

void* data
Image data buffer

unsigned int wdim
Image word size (in bytes)

WORD_KIND wordKind
Image word kind

SIGN sign
Image word sign

VECTORIAL_MODE vectMode
Data buffer vectors are interlaced or non interlaced

char** user
User defined strings array. The user can use any internal purpose string. Each string is written at then end of header after a '#' character.

unsigned int nuser
Number of user strings

IMAGE_FORMAT imageFormat
format of image source file

ImageInformation* info
Optional additional information

unsigned int getX() const
get image x dimension

unsigned int getY() const
get image y dimension

unsigned int getZ() const
get image z dimension

void setX(const unsigned int x)
set image x dimension

void setY(const unsigned int y)
set image y dimension

void setZ(const unsigned int z)
set image z dimension

void setVdim(const unsigned int v)
set image vectorial dimension

unsigned int getVdim(void) const
get image vectorial dimension

unsigned int getWdim(void) const
get image words size (in bytes)

float getVX() const
get image voxel size in x dimension

float getVY() const
get image voxel size in y dimension

float getVZ() const
get image voxel size in z dimension

void* getData() const
get image data buffer

unsigned int getWordSize() const
get image word size

WORD_KIND getWordKind() const
get word kind

SIGN getWordSign() const
get word sign

VECTORIAL_MODE getVectorialMode() const
get VECTORIAL_MODE

IMAGE_FORMAT getFileFormat(void) const
get image file format

void setFileFormat(IMAGE_FORMAT f)
set a new image file format for saving
Parameters:
f - new file format

Constructors

BaseInrimage(const char *name, bool headerOnly = false, VECTORIAL_MODE vm = VM_INTERLACED, VECTORIAL_MODE filevm = VM_INTERLACED) throw(ImageNotFound, UnknownImageType, InvalidHeader, InvalidData)
Reads inrimage from file whose path is given as argument. File can be an INRIMAGE(4) gzipped or not, an analyse, a GIF or an RGB irix file. If image has a vectorial type, it can be read interlaced (default) or non interlaced by giving WM_NON_INTERLACED as third argument. Ih headerOnly parameter is true, only image header is read.
Throws:
ImageNotFound image file was not found
UnknownImageType unknown image file format
InvalidData invalid inriamge header read
InvalidData invalid inriamge data read
Parameters:
name - inrimage file name
headerOnly - whether to read header or full image
vm - interlaced or non-interlaced mode for vectorial image
filevm - if VM_NON_INTERLACED, data is considered as non-interlaced

BaseInrimage(unsigned int xdim, unsigned int ydim, unsigned int zdim, unsigned int vdim = 1, unsigned int wdim = 1, WORD_KIND wordKind = WK_FIXED, SIGN sign = SGN_SIGNED, float vx = 1.0, float vy = 1.0, float vz = 1.0) throw(InvalidSize, NotEnoughMemory, InvalidVoxelSize)
Creates an inrimage with given size and word type. The inrimage data buffer is allocated.
Throws:
InvalidSize image dimension should be > 0
NotEnoughMemory unable to allocate memory to store image
InvalidVoxelSize voxels size should be > 0.0
Parameters:
xdim - image number of columns
ydim - image number of rows
zdim - image number of planes
vdim - image vectorial dimension
wdim - image word size in bytes
wordKind - image word kind
sign - image word sign
vx - distance between voxels in the X direction
vy - distance between voxels in the Y direction
vz - distance between voxels in the Z direction

BaseInrimage(unsigned int xdim, unsigned int ydim, unsigned int zdim, void *data, unsigned int vdim = 1, unsigned int wdim = 1, WORD_KIND wordKind = WK_FIXED, SIGN sign = SGN_SIGNED, float vx = 1.0, float vy = 1.0, float vz = 1.0) throw(InvalidSize, InvalidVoxelSize)
Creates an inrimage with given size and word type. If data is 0, the image is not allocated. If data is non 0, image data points to it.
Throws:
InvalidSize image dimension should be > 0
InvalidVoxelSize voxels size should be > 0.0
Parameters:
xdim - image number of columns
ydim - image number of rows
zdim - image number of planes
data - image data buffer
vdim - image vectorial dimension
wdim - image word size in bytes
wordKind - image word kind
sign - image word sign
vx - distance between voxels in the X direction
vy - distance between voxels in the Y direction
vz - distance between voxels in the Z direction

explicit BaseInrimage(const BaseInrimage& img) throw(InvalidSize, InvalidVectorialMode, InvalidVoxelSize, NotEnoughMemory)
creates an replica of img
Throws:
InvalidSize image dimension should be > 0
InvalidVectorialMode attempt to set a vector mode to a scalar image or opposite
InvalidVoxelSize voxels size should be > 0.0
NotEnoughMemory unable to allocate memory to store image
Parameters:
img - image to copy

Destructors

virtual ~BaseInrimage()
frees image buffer

void write(const char *name) const throw(UnableToCreateFile, UnableToWriteHeader, UnableToWriteData)
Writes inrimage to file whose path is given as argument. If file name ends with '.gz' suffix, file is gzipped.
Throws:
UnableToCreateFile file creation failed for writting
UnableToWriteHeader write error encountered while writting header
UnableToWriteData write error encountered while writting data
Parameters:
name - inrimage file name

BaseInrimage& operator=(const BaseInrimage& img) throw(InvalidSize, InvalidVectorialMode, InvalidVoxelSize, NotEnoughMemory)
Makes *this an replica of img
Throws:
InvalidSize image dimension should be > 0
InvalidVectorialMode attempt to set a vector mode to a scalar image or opposite
InvalidVoxelSize voxels size should be > 0.0
NotEnoughMemory unable to allocate memory to store image
Parameters:
img - image to copy

virtual void allocate(void) throw(NotEnoughMemory)
Allocates and fills with zero image data buffer. If data is not null, buffer is first fried.
Throws:
NotEnoughMemory unable to allocate memory to store image

virtual void free(void)
frees image data buffer

void setVoxelSize(float vx, float vy, float vz) throw(InvalidVoxelSize)
set a new image voxel size
Parameters:
vx - X voxel size
vy - Y voxel size
vz - Z voxel size
InvalidVoxelSize - invalid voxel size

virtual void* setData(void *data)
set a new data buffer. Returns old image data buffer. Use setVectorialMode(VECTORIAL_MODE vm) if vectMode has changed
Parameters:
data - new data buffer

virtual void setVectorialMode(VECTORIAL_MODE vm) throw(InvalidVectorialMode)
Changes image vectorial mode. A vectorial image buffer can be stored either interlaced (default) or non interlaced.
Throws:
InvalidVectorialMode attempt to set a vector mode to a scalar image or opposite
Parameters:
vm - new image vectorial mode

virtual void setInterlacedData(void)
toggles buffer to produce an interlaced vector image (for vectorial images only)

virtual void setNonInterlacedData(void)
toggles buffer to produce an interlaced vector image (for vectorial images only)

void setUserParams(unsigned int n, char **params)
set user defined parameters strings to write into image file header
Parameters:
n - number of strings
params - strings array

virtual void resize(unsigned int xdim, unsigned int ydim, unsigned int zdim, unsigned int vdim = 1, unsigned int wdim = 1, WORD_KIND wordKind = WK_FIXED, SIGN sign = SGN_SIGNED) throw(InvalidSize, NotEnoughMemory)
Changes image size. If image data buffer existed it is fried and reallocated.
Throws:
InvalidSize image dimension should be > 0
NotEnoughMemory unable to allocate memory to store image
Parameters:
xdim - image number of columns
ydim - image number of rows
zdim - image number of planes
vdim - image vectorial dimension
wdim - image word size in bytes
wordKind - image word kind
sign - image word sign

virtual void setWords(WORD_KIND wordKind = WK_FIXED, SIGN sign = SGN_SIGNED) throw(NotEnoughMemory)
Changes image word type. If image data buffer existed it is fried and reallocated.
Throws:
NotEnoughMemory unable to allocate memory to store image
Parameters:
image - word kind
image - word type

static BaseInrimage* _image2BaseInrimage(const _image& img) throw(BaseInrimage::InvalidSize, BaseInrimage::InvalidVoxelSize, BaseInrimage::InvalidVectorialMode)
Converts an _image structure to a BaseInrimage
Throws:
InvalidSize image dimension should be > 0
InvalidVoxelSize voxels size should be > 0.0
InvalidVectorialMode attempt to set a vector mode to a scalar image or opposite
Returns:
BaseInrimage object with same data buffer than img
Parameters:
img - _image structure

static _image* BaseInrimage2_image(const BaseInrimage& bimg)
Converts a BaseImage structure to an _image
Returns:
_image structure with same data buffer than bimg
Parameters:
img - BaseInrimage object

bool userField(const char *name, char *val, unsigned int n) const
Check whether given field exists in user defined strings. Looks for a field with following syntax: name [= val] If name is found and val buffer is not 0, field value is returned in val.
Returns:
true if field exists and false otherwise
Parameters:
name - researched field name
val - returned field value (buffer must have been previously allocated)
n - value buffer length

bool updateUserField(const char *name, const char *val) const
Check whether given field exists in user defined strings. Return true if field exists and false otherwise. Looks for a field with following syntax: name [= val] If name is found and val buffer is not NULL, field value is set to val.
Returns:
true if field exists and false otherwise
Parameters:
name - researched field name
val - value to give to field

void addUserField(const char *name, const char *val)
Add a given field to the user defined strings. Looks for a field with following syntax: name [= val] If name is found and val buffer is not NULL, field value is modified. Else, the field is added.
Parameters:
name - researched field name
val - value to give to field

bool removeUserField(const char *name)
Remove a given field to the user defined strings. Looks for a field with following syntax: name [= val] If name is found it is removed for the user field list.
Returns:
true if field was found and false otherwise
Parameters:
name - researched field name

template void rescaleBuffer(FROM, TO, double fmin, double fmax, double tmin, double tmax, double offset, BaseInrimage& img)
Rescale data values into another image. img needs to be already initialized to proper format. fmin and fmax are min and max values of this image's buffer. tmin and tmax are min and max values of resulting image's buffer.
Parameters:
fmin - minimum value of image
fmax - maximum value of image
tmin - minimum value of image
tmax - maximum value of image
offset - offset to add to every value.
img - image to put result in

void getBounds(double &min, double &max) const
compute grey level bounds of image buffer (valid for image scalar types only)
Parameters:
min - returned min value
max - returned max value

_image* readHeader(const char *name) throw(ImageNotFound, InvalidHeader, UnknownImageType)
open inrimage file and read header
Throws:
ImageNotFound image file was not found
InvalidHeader invalid inrimage header encountered
UnknownImageType unknown file format
Returns:
inrimage header, data is 0
Parameters:
name - inrimage file name


Direct child classes:
Inrimage

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de