Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

igtl_image.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Open ITK Link Library
00004   Module:    $RCSfile$
00005   Language:  C
00006   Date:      $Date: 2008-12-22 19:05:42 -0500 (Mon, 22 Dec 2008) $
00007   Version:   $Revision: 3460 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010 
00011   This software is distributed WITHOUT ANY WARRANTY; without even
00012   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00013   PURPOSE.  See the above copyright notices for more information.
00014 
00015 =========================================================================*/
00016 
00017 #ifndef __IGTL_IMAGE_H
00018 #define __IGTL_IMAGE_H
00019 
00020 #include "igtl_win32header.h"
00021 #include "igtl_util.h"
00022 #include "igtl_types.h"
00023 #include "igtl_win32header.h"
00024 
00025 #define IGTL_IMAGE_HEADER_VERSION       1
00026 #define IGTL_IMAGE_HEADER_SIZE          72
00027 
00028 /* Data type */
00029 #define IGTL_IMAGE_DTYPE_SCALAR         1
00030 #define IGTL_IMAGE_DTYPE_VECTOR         2
00031 
00032 /* Scalar type */
00033 #define IGTL_IMAGE_STYPE_TYPE_INT8      2
00034 #define IGTL_IMAGE_STYPE_TYPE_UINT8     3
00035 #define IGTL_IMAGE_STYPE_TYPE_INT16     4
00036 #define IGTL_IMAGE_STYPE_TYPE_UINT16    5
00037 #define IGTL_IMAGE_STYPE_TYPE_INT32     6
00038 #define IGTL_IMAGE_STYPE_TYPE_UINT32    7
00039 #define IGTL_IMAGE_STYPE_TYPE_FLOAT32   10
00040 #define IGTL_IMAGE_STYPE_TYPE_FLOAT64   11
00041 
00042 /* Endian */
00043 #define IGTL_IMAGE_ENDIAN_BIG           1
00044 #define IGTL_IMAGE_ENDIAN_LITTLE        2
00045 
00046 /* Image coordinate system */
00047 #define IGTL_IMAGE_COORD_RAS            1
00048 #define IGTL_IMAGE_COORD_LPS            2
00049 
00050 #ifdef __cplusplus
00051 extern "C" {
00052 #endif
00053 
00054 #pragma pack(1)     /* For 1-byte boundary in memroy */
00055 
00056 /*
00057  * Image data header for OpenIGTLinik protocol
00058  *
00059  * Image data consists of image data header, which is defined in this
00060  * structure, folowed by array of image pixel data.
00061  * igtl_image_header helps a receiver to load array of image pixel data.
00062  * The header supports "partial volume update", where a fraction of volume
00063  * image is transferred from a sender to receiver. This fraction called
00064  * "sub-volume" in this protocol, and its size and starting index is
00065  * specified in 'subvol_size' and 'subvol_offset'.
00066  * In case of transferring entire image in one message, 'size' and
00067  * 'subvol_size' should be same, and 'subvol_offset' equals (0, 0, 0).
00068  */
00069 
00070 typedef struct {
00071   igtl_uint16    version;          /* data format version number      */
00072   igtl_uint8     data_type;        /* data type (scalar or vector)    */
00073   igtl_uint8     scalar_type;      /* scalar type                     */
00074   igtl_uint8     endian;           /* endian type of image data       */
00075   igtl_uint8     coord;            /* coordinate system (LPS or RAS)  */
00076   igtl_uint16    size[3];          /* entire image volume size        */
00077   igtl_float32   matrix[12];       /* orientation / origin of image   */
00078                                    /*  - matrix[0-2]: norm_i * pix_i  */
00079                                    /*  - matrix[3-5]: norm_j * pix_j  */
00080                                    /*  - matrix[6-8]: norm_k * pix_k  */
00081                                    /*  - matrix[9-11]:origin          */
00082                                    /* where norm_* are normal vectors */
00083                                    /* along each index, and pix_* are */
00084                                    /* pixel size in each direction    */
00085 
00086   igtl_uint16    subvol_offset[3]; /* sub volume offset               */
00087   igtl_uint16    subvol_size[3];   /* sub volume size                 */
00088 } igtl_image_header;
00089 
00090 #pragma pack()
00091 
00092 
00093 /*
00094  * Image data size
00095  *
00096  * This function calculates size of the pixel array, which will be
00097  * transferred with the specified header.
00098  */
00099 
00100 igtl_uint64 igtl_export igtl_image_get_data_size(igtl_image_header * header);
00101 
00102 
00103 /*
00104  * Generate matrix 
00105  *
00106  * This function generates image orientation/origin matrix from 
00107  * spacing, origin and normal vectors.
00108  */
00109 
00110 void igtl_export igtl_image_set_matrix(float spacing[3], float origin[3],
00111                             float norm_i[3], float norm_j[3], float norm_k[3],
00112                             igtl_image_header * header);
00113 
00114 void igtl_export igtl_image_get_matrix(float spacing[3], float origin[3],
00115                             float norm_i[3], float norm_j[3], float norm_k[3],
00116                             igtl_image_header * header);
00117 
00118 /*
00119  * Byte order conversion for the header structure
00120  *
00121  * This function converts endianness of each member variable
00122  * in igtl_image_header from host byte order to network byte order,
00123  * or vice versa.
00124  */
00125 
00126 void igtl_export igtl_image_convert_byte_order(igtl_image_header * header);
00127 
00128 
00129 /*
00130  * CRC calculation
00131  *
00132  * This function calculates CRC of image data body including header
00133  * and array of pixel data.
00134  *
00135  */
00136 
00137 igtl_uint64 igtl_export igtl_image_get_crc(igtl_image_header * header, void* image);
00138 
00139 #ifdef __cplusplus
00140 }
00141 #endif
00142 
00143 #endif /* __IGTL_IMAGE_H */
00144 

Generated at Sat May 9 04:47:22 2009 for OpenIGTLink by doxygen 1.5.9 written by Dimitri van Heesch, © 1997-2000