BWAPI
|
#include <CGAL/compiler_config.h>
#include <CGAL/auto_link/ImageIO.h>
#include <stdlib.h>
#include <stdio.h>
#include <boost/cstdint.hpp>
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 imformat * | PTRIMAGE_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 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 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
enum DATA_MODE |
enum ENDIANNESS |
enum OPEN_MODE |
enum SIGN |
enum VECTORIAL_MODE |
enum WORD_KIND |
void _closeImage | ( | _image * | im | ) |
close an image file descriptor that was opened using _openImage
im | opened 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
x | image x dimension (number of columns) |
y | image y dimension (number of rows) |
z | image z dimension (number of planes) |
v | image vectorial dimension |
vx | image voxel size in x dimension |
vy | image voxel size in y dimension |
vz | image voxel size in z dimension |
w | image word size in bytes |
wk | image word kind |
sgn | image word sign |
void _freeImage | ( | _image * | im | ) |
Free an image descriptor
im | image 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
im | opened 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.
im | image descriptor |
_image* _initImage | ( | ) |
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
im | initialized image descriptor |
name | image 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.
im | initialized image descriptor |
name | image 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/
name | image file name or NULL for stdin |
_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).
int _readImageData | ( | _image * | im | ) |
Reads body from an inrmage whose header has been read by _readImageHeader
im | image 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
name | image file name or NULL |
_image* _readImageHeaderAndGetError | ( | const char * | name, |
int * | error | ||
) |
int _readNonInterlacedFileData | ( | _image * | im | ) |
Reads body from a non-interlaced vectorial inrimage whose header has been read by _readImageHeader. The image buffer is interlaced.
im | image 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)
name | image file name or NULL |
int _readNonInterlacedImageData | ( | _image * | im | ) |
Reads body from a vectorial inrimage whose header has been read by _readImageHeader. The image is uninterlaced (see _readNonInterlacedImage for details).
im | image 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.
im | image descriptor |
name | file name to store image or NULL |
int addImageFormat | ( | PTRIMAGE_FORMAT | format | ) |
adds a format in the list of image format. Test if all mandatory fields have been filled
format | : an image format |
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 | ||
) |
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
im | image to read |
buf | data buffer to read |
len | buffer 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
im | image to write |
buf | data buffer to write |
len | buffer length |
PTRIMAGE_FORMAT imageType | ( | const char * | fileName | ) |
return image type in given file
fileName | image file name |
void initSupportedFileFormat | ( | ) |
initializes the list of supported image formats
void printSupportedFileFormat | ( | ) |
prints supported image formats
void removeSupportedFileFormat | ( | ) |
free the list of supported image formats
void setImageIOAllocationRoutines | ( | ALLOCATION_FUNCTION | alloc, |
DEALLOCATION_FUNCTION | del | ||
) |
set allocation and deallocation routines
alloc | new allocation routine |
del | new deallocation routine |
float trilinear_interpolation | ( | const _image * | image, |
float | posx, | ||
float | posy, | ||
float | posz | ||
) | [inline] |
Alias for triLinInterp
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).