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.
1 /*=========================================================================
2 
3  Program: OpenIGTLink Library
4  Module: $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink/Source/igtlutil/igtl_image.h $
5  Language: C
6  Date: $Date: 2011-03-24 00:08:23 -0400 (Thu, 24 Mar 2011) $
7  Version: $Revision: 7354 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notices for more information.
14 
15 =========================================================================*/
16 
17 #ifndef __IGTL_IMAGE_H
18 #define __IGTL_IMAGE_H
19 
20 #include "igtl_win32header.h"
21 #include "igtl_util.h"
22 #include "igtl_types.h"
23 #include "igtl_win32header.h"
24 
25 #define IGTL_IMAGE_HEADER_VERSION 1
26 #define IGTL_IMAGE_HEADER_SIZE 72
27 
28 /* Data type */
29 #define IGTL_IMAGE_DTYPE_SCALAR 1
30 #define IGTL_IMAGE_DTYPE_VECTOR 3
31 
32 /* Scalar type */
33 #define IGTL_IMAGE_STYPE_TYPE_INT8 2
34 #define IGTL_IMAGE_STYPE_TYPE_UINT8 3
35 #define IGTL_IMAGE_STYPE_TYPE_INT16 4
36 #define IGTL_IMAGE_STYPE_TYPE_UINT16 5
37 #define IGTL_IMAGE_STYPE_TYPE_INT32 6
38 #define IGTL_IMAGE_STYPE_TYPE_UINT32 7
39 #define IGTL_IMAGE_STYPE_TYPE_FLOAT32 10
40 #define IGTL_IMAGE_STYPE_TYPE_FLOAT64 11
41 
42 /* Endian */
43 #define IGTL_IMAGE_ENDIAN_BIG 1
44 #define IGTL_IMAGE_ENDIAN_LITTLE 2
45 
46 /* Image coordinate system */
47 #define IGTL_IMAGE_COORD_RAS 1
48 #define IGTL_IMAGE_COORD_LPS 2
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 #pragma pack(1) /* For 1-byte boundary in memroy */
55 
56 /*
57  * Image data header for OpenIGTLinik protocol
58  *
59  * Image data consists of image data header, which is defined in this
60  * structure, folowed by array of image pixel data.
61  * igtl_image_header helps a receiver to load array of image pixel data.
62  * The header supports "partial volume update", where a fraction of volume
63  * image is transferred from a sender to receiver. This fraction called
64  * "sub-volume" in this protocol, and its size and starting index is
65  * specified in 'subvol_size' and 'subvol_offset'.
66  * In case of transferring entire image in one message, 'size' and
67  * 'subvol_size' should be same, and 'subvol_offset' equals (0, 0, 0).
68  */
69 
70 typedef struct {
71  igtl_uint16 version; /* data format version number(1) */
72  igtl_uint8 num_components; /* number of components per element*/
73  igtl_uint8 scalar_type; /* scalar type */
74  /*2:int8 3:uint8 4:int16 5:uint16 6:int32 7:uint32 10:float32 11:float64) */
75  igtl_uint8 endian; /* endian type of image data */
76  /* (1:big, 2:little) */
77  igtl_uint8 coord; /* coordinate system (1:RAS 2:LPS) */
78  igtl_uint16 size[3]; /* entire image volume size */
79  igtl_float32 matrix[12]; /* orientation / origin of image */
80  /* - matrix[0-2]: norm_i * pix_i */
81  /* - matrix[3-5]: norm_j * pix_j */
82  /* - matrix[6-8]: norm_k * pix_k */
83  /* - matrix[9-11]:origin */
84  /* where norm_* are normal vectors */
85  /* along each index, and pix_* are */
86  /* pixel size in each direction */
87 
88  igtl_uint16 subvol_offset[3]; /* sub volume offset */
89  igtl_uint16 subvol_size[3]; /* sub volume size */
91 
92 #pragma pack()
93 
94 
95 /*
96  * Image data size
97  *
98  * This function calculates size of the pixel array, which will be
99  * transferred with the specified header.
100  */
101 
103 
104 
105 /*
106  * Generate matrix
107  *
108  * This function generates image orientation/origin matrix from
109  * spacing, origin and normal vectors.
110  */
111 
112 void igtl_export igtl_image_set_matrix(float spacing[3], float origin[3],
113  float norm_i[3], float norm_j[3], float norm_k[3],
114  igtl_image_header * header);
115 
116 void igtl_export igtl_image_get_matrix(float spacing[3], float origin[3],
117  float norm_i[3], float norm_j[3], float norm_k[3],
118  igtl_image_header * header);
119 
120 /*
121  * Byte order conversion for the header structure
122  *
123  * This function converts endianness of each member variable
124  * in igtl_image_header from host byte order to network byte order,
125  * or vice versa.
126  */
127 
129 
130 
131 /*
132  * CRC calculation
133  *
134  * This function calculates CRC of image data body including header
135  * and array of pixel data.
136  *
137  */
138 
139 igtl_uint64 igtl_export igtl_image_get_crc(igtl_image_header * header, void* image);
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif /* __IGTL_IMAGE_H */
146 

Generated at Thu Mar 20 2014 16:32:06 for OpenIGTLink by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2000