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:   OpenIGTLink Library
00004   Module:    $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink/Source/igtlutil/igtl_image.h $
00005   Language:  C
00006   Date:      $Date: 2011-03-24 00:08:23 -0400 (Thu, 24 Mar 2011) $
00007   Version:   $Revision: 7354 $
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         3
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(1)   */
00072   igtl_uint8     num_components;   /* number of components per element*/
00073   igtl_uint8     scalar_type;      /* scalar type                     */
00074   /*2:int8 3:uint8 4:int16 5:uint16 6:int32 7:uint32 10:float32 11:float64) */
00075   igtl_uint8     endian;           /* endian type of image data       */
00076                                    /* (1:big, 2:little)               */ 
00077   igtl_uint8     coord;            /* coordinate system (1:RAS 2:LPS) */
00078   igtl_uint16    size[3];          /* entire image volume size        */
00079   igtl_float32   matrix[12];       /* orientation / origin of image   */
00080                                    /*  - matrix[0-2]: norm_i * pix_i  */
00081                                    /*  - matrix[3-5]: norm_j * pix_j  */
00082                                    /*  - matrix[6-8]: norm_k * pix_k  */
00083                                    /*  - matrix[9-11]:origin          */
00084                                    /* where norm_* are normal vectors */
00085                                    /* along each index, and pix_* are */
00086                                    /* pixel size in each direction    */
00087 
00088   igtl_uint16    subvol_offset[3]; /* sub volume offset               */
00089   igtl_uint16    subvol_size[3];   /* sub volume size                 */
00090 } igtl_image_header;
00091 
00092 #pragma pack()
00093 
00094 
00095 /*
00096  * Image data size
00097  *
00098  * This function calculates size of the pixel array, which will be
00099  * transferred with the specified header.
00100  */
00101 
00102 igtl_uint64 igtl_export igtl_image_get_data_size(igtl_image_header * header);
00103 
00104 
00105 /*
00106  * Generate matrix 
00107  *
00108  * This function generates image orientation/origin matrix from 
00109  * spacing, origin and normal vectors.
00110  */
00111 
00112 void igtl_export igtl_image_set_matrix(float spacing[3], float origin[3],
00113                             float norm_i[3], float norm_j[3], float norm_k[3],
00114                             igtl_image_header * header);
00115 
00116 void igtl_export igtl_image_get_matrix(float spacing[3], float origin[3],
00117                             float norm_i[3], float norm_j[3], float norm_k[3],
00118                             igtl_image_header * header);
00119 
00120 /*
00121  * Byte order conversion for the header structure
00122  *
00123  * This function converts endianness of each member variable
00124  * in igtl_image_header from host byte order to network byte order,
00125  * or vice versa.
00126  */
00127 
00128 void igtl_export igtl_image_convert_byte_order(igtl_image_header * header);
00129 
00130 
00131 /*
00132  * CRC calculation
00133  *
00134  * This function calculates CRC of image data body including header
00135  * and array of pixel data.
00136  *
00137  */
00138 
00139 igtl_uint64 igtl_export igtl_image_get_crc(igtl_image_header * header, void* image);
00140 
00141 #ifdef __cplusplus
00142 }
00143 #endif
00144 
00145 #endif /* __IGTL_IMAGE_H */
00146 

Generated at Sat Dec 3 2011 08:54:20 for OpenIGTLink by doxygen 1.7.4 written by Dimitri van Heesch, © 1997-2000