BWAPI
Classes | Namespaces | Defines | Typedefs | Enumerations | Functions
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/ImageIO.h File Reference
#include <CGAL/compiler_config.h>
#include <CGAL/auto_link/ImageIO.h>
#include <stdlib.h>
#include <stdio.h>
#include <boost/cstdint.hpp>
Include dependency graph for ImageIO.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  imformat
struct  point_image
struct  CGAL::IMAGEIO::Word_type_generator< wordKind, sign, wdim >
struct  CGAL::IMAGEIO::Word_type_generator< WK_FLOAT, sign, 4 >
struct  CGAL::IMAGEIO::Word_type_generator< WK_FLOAT, sign, 8 >
struct  CGAL::IMAGEIO::Word_type_generator< WK_FIXED, SGN_SIGNED, 1 >
struct  CGAL::IMAGEIO::Word_type_generator< WK_FIXED, SGN_UNSIGNED, 1 >
struct  CGAL::IMAGEIO::Word_type_generator< WK_FIXED, SGN_SIGNED, 2 >
struct  CGAL::IMAGEIO::Word_type_generator< WK_FIXED, SGN_UNSIGNED, 2 >
struct  CGAL::IMAGEIO::Word_type_generator< WK_FIXED, SGN_SIGNED, 4 >
struct  CGAL::IMAGEIO::Word_type_generator< WK_FIXED, SGN_UNSIGNED, 4 >

Namespaces

namespace  CGAL
namespace  CGAL::IMAGEIO

Defines

#define LONGINT   long int
#define IMAGE_FORMAT_NAME_LENGTH   100
#define ImageIO_NO_ERROR   0
#define ImageIO_UNKNOWN_TYPE   -1
#define ImageIO_OPENING   -2
#define ImageIO_READING_HEADER   -3
#define ImageIO_READING_IMAGE   -4
#define ImageIO_WRITING_HEADER   -3
#define ImageIO_WRITING_IMAGE   -4
#define ImageIO_WRITING_DATA   -5
#define CGAL_IMAGE_IO_CASE(image_ptr, code)

Typedefs

typedef FILE * _ImageIO_file
typedef int(* TEST_IMAGE_FORMAT )(char *, const char *)
typedef int(* READ_IMAGE_HEADER )(const char *, struct point_image *)
typedef int(* WRITE_IMAGE )(char *, struct point_image *)
typedef struct imformat IMAGE_FORMAT
typedef struct imformatPTRIMAGE_FORMAT
typedef struct point_image _image
typedef void *(* ALLOCATION_FUNCTION )(size_t)
typedef void(* DEALLOCATION_FUNCTION )(void *)

Enumerations

enum  OPEN_MODE { OM_CLOSE, OM_STD, OM_FILE }
enum  DATA_MODE { DM_BINARY, DM_ASCII }
enum  WORD_KIND { WK_FIXED, WK_FLOAT, WK_UNKNOWN }
enum  SIGN { SGN_SIGNED, SGN_UNSIGNED, SGN_UNKNOWN }
enum  ENDIANNESS { END_LITTLE, END_BIG, END_UNKNOWN }
enum  VECTORIAL_MODE { VM_INTERLACED, VM_NON_INTERLACED, VM_SCALAR }

Functions

_image_initImage ()
void _freeImage (_image *im)
_image_createImage (int x, int y, int z, int v, float vx, float vy, float vz, int w, WORD_KIND wk, SIGN sgn)
_image_readImage (const char *name)
_image_readNonInterlacedImage (const char *name)
_image_readImage_raw (const char *name, const unsigned int rx, const unsigned int ry, const unsigned int rz, const double vx=1., const double vy=1., const double vz=1., const unsigned int offset=0)
int _writeImage (_image *im, const char *name)
void _getNextSlice (_image *im)
int addImageFormat (PTRIMAGE_FORMAT format)
PTRIMAGE_FORMAT firstImageFormat ()
_image_readImageHeader (const char *name)
_image_readImageHeaderAndGetError (const char *name, int *error)
int _readImageData (_image *im)
int _readNonInterlacedImageData (_image *im)
int _readNonInterlacedFileData (_image *im)
void _openWriteImage (_image *im, const char *name)
void _openReadImage (_image *im, const char *name)
void _closeImage (_image *im)
void _get_image_bounding_box (_image *im, double *x_min, double *y_min, double *z_min, double *x_max, double *y_max, double *z_max)
ENDIANNESS _getEndianness ()
void initSupportedFileFormat ()
void printSupportedFileFormat ()
void removeSupportedFileFormat ()
PTRIMAGE_FORMAT imageType (const char *fileName)
void setImageIOAllocationRoutines (ALLOCATION_FUNCTION alloc, DEALLOCATION_FUNCTION del)
void * ImageIO_alloc (size_t)
void ImageIO_free (void *)
size_t ImageIO_write (const _image *im, const void *buf, size_t len)
size_t ImageIO_read (const _image *im, void *buf, size_t len)
char * ImageIO_gets (const _image *im, char *str, int size)
int ImageIO_seek (const _image *im, long offset, int whence)
int ImageIO_error (const _image *im)
int ImageIO_close (_image *im)
float triLinInterp (const _image *image, float posx, float posy, float posz, const float value_outside=0.)
float trilinear_interpolation (const _image *image, float posx, float posy, float posz)
template<WORD_KIND wordKind, SIGN sign, unsigned int wdim>
Word_type_generator< wordKind,
sign, wdim >::type 
CGAL::IMAGEIO::static_evaluate (const _image *image, const unsigned int i, const unsigned int j, const unsigned int k)
template<typename Word >
Word CGAL::IMAGEIO::static_evaluate (const _image *image, const unsigned int i, const unsigned int j, const unsigned int k)
float evaluate (const _image *image, const unsigned int i, const unsigned int j, const unsigned int k)
void convertImageTypeToFloat (_image *image)

Define Documentation

#define CGAL_IMAGE_IO_CASE (   image_ptr,
  code 
)
#define IMAGE_FORMAT_NAME_LENGTH   100
#define ImageIO_NO_ERROR   0

Error codes

#define ImageIO_OPENING   -2
#define ImageIO_READING_HEADER   -3
#define ImageIO_READING_IMAGE   -4
#define ImageIO_UNKNOWN_TYPE   -1
#define ImageIO_WRITING_DATA   -5
#define ImageIO_WRITING_HEADER   -3
#define ImageIO_WRITING_IMAGE   -4
#define LONGINT   long int

Typedef Documentation

typedef struct point_image _image

Image descriptor

typedef FILE* _ImageIO_file
typedef void*(* ALLOCATION_FUNCTION)(size_t)

function prototype to allocate memory

typedef void(* DEALLOCATION_FUNCTION)(void *)

function prototype to free memory

typedef struct imformat IMAGE_FORMAT

Image Format descriptor

typedef struct imformat * PTRIMAGE_FORMAT
typedef int(* READ_IMAGE_HEADER)(const char *, struct point_image *)

defines the type of function called to read an image or an image header from a file corresponding to a given format. The first parameter is the file name whereas the second parameter is an _image structure. Note that the file has been already opened (the file descriptor fd is valid). The output value is >0 if the whole image has been read, it is 0 if only the header has been read and it is <0 otherwise

typedef int(* TEST_IMAGE_FORMAT)(char *, const char *)

defines the type of function called to test if an image is of a given format. The first parameter is an array of char of size 5 (ends with character 0) that describes the first file character (magic string). The second parameter is the filename. The output value is >=0 if the image is of that given format and <0 otherwise

typedef int(* WRITE_IMAGE)(char *, struct point_image *)

defines the type of function called to write an image to a file corresponding to a given format. The first parameter is the full file name whereas the second parameter is an _image structure. Note that the file has to be opened and closed in the function. The output value is >=0 if the whole image has been written correctly and it is <0 otherwise


Enumeration Type Documentation

enum DATA_MODE

data mode

Enumerator:
DM_BINARY 

data are binary

DM_ASCII 

data are ascii

enum ENDIANNESS

endianness

Enumerator:
END_LITTLE 

Little endian processor

END_BIG 

Big endian processor

END_UNKNOWN 

Unknown endianness (unopenned file)

enum OPEN_MODE

file open mode

Enumerator:
OM_CLOSE 

no file open

OM_STD 

file is stdin or stdout

OM_FILE 

file is gzipped normal file

enum SIGN

image word sign

Enumerator:
SGN_SIGNED 

signed

SGN_UNSIGNED 

unsigned

SGN_UNKNOWN 

unknown (uninitialized or floating point words)

inrimage vectorial storage mode

Enumerator:
VM_INTERLACED 

interlaced vectors (i.e. x1, y1, z1, x2, y2, z2, x3, y3, z3, ...)

VM_NON_INTERLACED 

non interlaced vectors (i.e. x1, x2, x3, ..., y1, y2, y3, ..., z1, z2, z3...)

VM_SCALAR 

scalar inrimage

enum WORD_KIND

kind of image word

Enumerator:
WK_FIXED 

fixed type

WK_FLOAT 

floating point

WK_UNKNOWN 

unknown (uninitialized)


Function Documentation

void _closeImage ( _image im)

close an image file descriptor that was opened using _openImage

Parameters:
imopened image descriptor
_image* _createImage ( int  x,
int  y,
int  z,
int  v,
float  vx,
float  vy,
float  vz,
int  w,
WORD_KIND  wk,
SIGN  sgn 
)

creates an image descriptor from the given header information

Parameters:
ximage x dimension (number of columns)
yimage y dimension (number of rows)
zimage z dimension (number of planes)
vimage vectorial dimension
vximage voxel size in x dimension
vyimage voxel size in y dimension
vzimage voxel size in z dimension
wimage word size in bytes
wkimage word kind
sgnimage word sign
void _freeImage ( _image im)

Free an image descriptor

Parameters:
imimage descriptor
void _get_image_bounding_box ( _image im,
double *  x_min,
double *  y_min,
double *  z_min,
double *  x_max,
double *  y_max,
double *  z_max 
)

return the bounding box of the image

Parameters:
imopened image descriptor

returns the endianness of the hardware architecture

void _getNextSlice ( _image im)

Read one slice of given image whose header has already been read.
File descriptor is let at the beginning of next slice and closed
when end of file is encountered.
If data buffer is NULL, it is allocated for one slice only.
This funtion is dedicated to read huge inrimages.

Parameters:
imimage descriptor

Allocates and initializes an image descriptor

void _openReadImage ( _image im,
const char *  name 
)

open an image file from stdin (if name == NULL), from a pipe (piped with gzip if image was compressed) or from a standard file

Parameters:
iminitialized image descriptor
nameimage file name
void _openWriteImage ( _image im,
const char *  name 
)

given an initialized file descriptor and a file name, open file from stdout (if name == NULL), a gziped pipe (if file is gziped) or a standard file otherwise.

Parameters:
iminitialized image descriptor
nameimage file name
_image* _readImage ( const char *  name)

Reads an image from a file and returns an image descriptor or NULL if
reading failed.
Reads from stdin if image name is NULL. The image data field points to a xdim * ydim * zdim * vdim buffer containing voxels in order: (Z1, Y1, X1, V1) (Z1, Y1, X1, V2), ... , (Z1, Y1, X1, Vt), (Z1, Y1, X2, V1) ... ... , (Z1, Y1, X2, Vt), ... (Z1, Y1, Xn, V1) ... ... , (Z1, Y1, Xn, Vt), (Z1, Y2, X1, V1) ... ... , (Z1, Y2, X1, Vt), ... (Z2, Y1, X1, V1) ... ... , (Z2, Y1, X1, Vt), ... ... ... , (Zl, Ym, Xn, Vt)

Read the following format: Inrimage, GIF, IRIS, ANALYSE, PGM, PPM, BMP, GIS (CEA, IRISA, ENST 3D image format).

See also: http://www.dcs.ed.ac.uk/home/mxr/gfx/2d-hi.html and http://www.gzip.org/zlib/

Parameters:
nameimage file name or NULL for stdin

Here is the caller graph for this function:

_image* _readImage_raw ( const char *  name,
const unsigned int  rx,
const unsigned int  ry,
const unsigned int  rz,
const double  vx = 1.,
const double  vy = 1.,
const double  vz = 1.,
const unsigned int  offset = 0 
)

Read an image from a file. The word type is supposed to be unsigned char, and the dimensions are (rx, ry, rz).

Here is the caller graph for this function:

int _readImageData ( _image im)

Reads body from an inrmage whose header has been read by _readImageHeader

Parameters:
imimage to read
_image* _readImageHeader ( const char *  name)

Reads header from an image file
If file is an inrimage, only header is read. Otherwise, whole image
is read and image file descriptor is closed.
If name is NULL, header is read from STDIN

Parameters:
nameimage file name or NULL
_image* _readImageHeaderAndGetError ( const char *  name,
int *  error 
)

Reads body from a non-interlaced vectorial inrimage whose header has been read by _readImageHeader. The image buffer is interlaced.

Parameters:
imimage descriptor
_image* _readNonInterlacedImage ( const char *  name)

Reads an image from a file and returns an image descriptor or NULL if
reading failed.
Reads from stdin if image name is NULL. If the image is vectorial, it is uninterlaced, i.e. the image data field points to a xdim * ydim * zdim * vdim buffer containing voxels in order: (V1, Z1, Y1, X1) (V1, Z1, Y1, X2), ... , (V1, Z1, Y1, Xn), (V1, Z1, Y2, X1) ... ... , (V1, Z1, Y2, Xn), ... (V1, Z1, Ym, X1) ... ... , (V1, Z1, Ym, Xn), (V1, Z2, Y1, X1) ... ... , (V1, Z2, Y1, Xn), ... (V2, Z1, Y1, X1) ... ... , (V2, Z1, Y1, Xn), ... ... ... , (Vt, Zl, Ym, Xn)

Parameters:
nameimage file name or NULL

Reads body from a vectorial inrimage whose header has been read by _readImageHeader. The image is uninterlaced (see _readNonInterlacedImage for details).

Parameters:
imimage descriptor
int _writeImage ( _image im,
const char *  name 
)

Writes given image in file 'name'.
If name ends with '.gz', file is gzipped.
If name is NULL, image is sent to stdout.

Parameters:
imimage descriptor
namefile name to store image or NULL

adds a format in the list of image format. Test if all mandatory fields have been filled

Parameters:
format: an image format
Returns:
-1 if it failed (missing information) and 0 if it succeeded
void convertImageTypeToFloat ( _image image)

convert the data of the image to float

float evaluate ( const _image image,
const unsigned int  i,
const unsigned int  j,
const unsigned int  k 
)

Here is the caller graph for this function:

returns the first available image format

void* ImageIO_alloc ( size_t  )

call allocation routine

int ImageIO_close ( _image im)

replaces fclose function

int ImageIO_error ( const _image im)

replaces ferror function

void ImageIO_free ( void *  )

call deallocation routine

char* ImageIO_gets ( const _image im,
char *  str,
int  size 
)

replaces fgets function

size_t ImageIO_read ( const _image im,
void *  buf,
size_t  len 
)

replaces fread function

Parameters:
imimage to read
bufdata buffer to read
lenbuffer length
int ImageIO_seek ( const _image im,
long  offset,
int  whence 
)

replaces fseek function

size_t ImageIO_write ( const _image im,
const void *  buf,
size_t  len 
)

replaces fwrite function

Parameters:
imimage to write
bufdata buffer to write
lenbuffer length
PTRIMAGE_FORMAT imageType ( const char *  fileName)

return image type in given file

Parameters:
fileNameimage file name

initializes the list of supported image formats

prints supported image formats

Here is the caller graph for this function:

free the list of supported image formats

set allocation and deallocation routines

Parameters:
allocnew allocation routine
delnew deallocation routine
float trilinear_interpolation ( const _image image,
float  posx,
float  posy,
float  posz 
) [inline]

Alias for triLinInterp

Here is the call graph for this function:

float triLinInterp ( const _image image,
float  posx,
float  posy,
float  posz,
const float  value_outside = 0. 
)

trilinear interpolation in an _image. The returned type is float (cast are made if the image word type is different).

Here is the caller graph for this function:

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines