Doxygen Source Code Documentation
        
Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search   
mri_image.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 #ifndef _MCW_MRIIMAGE_HEADER_
00008 #define _MCW_MRIIMAGE_HEADER_
00009 
00010 
00011 
00012 
00013 
00014 #ifndef TYPEDEF_byte
00015 #define TYPEDEF_byte
00016 typedef unsigned char byte ;
00017 #endif
00018 
00019 
00020 
00021 #ifndef TYPEDEF_rgba
00022 #define TYPEDEF_rgba
00023 typedef struct { byte r,g,b,a ; } rgba ;  
00024 #endif
00025 
00026 #define LOAD_rgba(s,rr,gg,bb,aa)   ((s).r=(rr),(s).g=(gg),(s).b=(bb),(s).a=(bb))
00027 #define UNLOAD_rgba(s,rr,gg,bb,aa) ((rr)=(s).r,(gg)=(s).g,(bb)=(s).b,(aa)=(s).a)
00028 
00029 
00030 
00031 typedef enum MRI_TYPE {
00032          MRI_byte , MRI_short  , MRI_int  ,
00033         MRI_float , MRI_double , MRI_complex , MRI_rgb , MRI_rgba } MRI_TYPE ;
00034 
00035 #define MRI_KIND MRI_TYPE ;   
00036 #define MRI_type MRI_TYPE ;
00037 #define MRI_kind MRI_TYPE ;
00038 
00039 #define MRI_rgbyte MRI_rgb
00040 
00041 
00042 
00043 #define LAST_MRI_TYPE 7
00044 
00045 
00046 
00047 #define MRI_maxbyte         255
00048 
00049 
00050 
00051 #define MRI_maxshort      32767
00052 
00053 
00054 
00055 #define MRI_maxint   2147483647
00056 
00057 
00058 
00059 #define MRI_IS_INT_TYPE(typ) ((typ) < 3)
00060 
00061 
00062 
00063 #ifdef _SUNPERF_COMPLEX
00064 # define TYPEDEF_complex
00065 #endif
00066 
00067 #ifndef TYPEDEF_complex
00068 #define TYPEDEF_complex
00069 typedef struct complex { float r , i ; } complex ;
00070 #endif
00071 
00072 
00073 
00074 
00075 
00076 #ifndef TYPEDEF_rgbyte
00077 #define TYPEDEF_rgbyte
00078 typedef struct rgbyte { byte r,g,b ; } rgbyte ;  
00079 #endif
00080 
00081 
00082 
00083 
00084 
00085 
00086 typedef union MRI_DATA {
00087          byte     *byte_data ;
00088          short    *short_data ;
00089          int      *int_data ;
00090          float    *float_data ;
00091          double   *double_data ;
00092          complex  *complex_data ;
00093          byte     *rgb_data ;      
00094          rgba     *rgba_data ;     
00095 } MRI_DATA ;
00096 
00097 
00098 
00099 
00100 
00101 #undef USE_MRI_LABELS
00102 #ifdef USE_MRI_LABELS
00103 #  define MRI_LABEL_SIZE 4
00104 #endif
00105 
00106 #define USE_MRI_DELAY   
00107 #ifdef USE_MRI_DELAY
00108 #  define INPUT_DELAY  1
00109 #  define BSWAP_DELAY  2
00110 #endif
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 typedef struct MRI_IMAGE {
00122           int nx ;            
00123           int ny ;            
00124           int nz  ;           
00125           int nt ;            
00126           int nu ;            
00127           int nv ;            
00128           int nw  ;           
00129           int nxy ;           
00130           int nxyz ;          
00131           int nxyzt  ;        
00132           int nvox   ;        
00133           int pixel_size ;    
00134 
00135           MRI_TYPE kind ;     
00136           MRI_DATA im ;       
00137           char *name ;        
00138 
00139           float dx ;          
00140           float dy ;          
00141           float dz ;          
00142           float dt ;          
00143           float du ;          
00144           float dv ;          
00145           float dw ;          
00146           float xo ;          
00147           float yo ;          
00148           float zo ;          
00149           float to ;          
00150           float uo ;          
00151           float vo ;          
00152           float wo ;          
00153 
00154 #ifdef USE_MRI_LABELS
00155          char xlab[MRI_LABEL_SIZE] ;  
00156               ylab[MRI_LABEL_SIZE] ;  
00157               zlab[MRI_LABEL_SIZE] ;  
00158               tlab[MRI_LABEL_SIZE] ;  
00159               ulab[MRI_LABEL_SIZE] ;  
00160               vlab[MRI_LABEL_SIZE] ;  
00161               wlab[MRI_LABEL_SIZE] ;  
00162 #endif
00163 
00164 #ifdef USE_MRI_DELAY
00165          char *fname ;   
00166          int foffset ;   
00167          int fondisk ;   
00168 #endif
00169 
00170          int was_swapped ; 
00171 } MRI_IMAGE ;
00172 
00173 #ifdef USE_MRI_LABELS
00174 
00175 #  define MRI_COPY_AUX(nn,oo)                                           \
00176     ( (nn)->dx = (oo)->dx , (nn)->dy = (oo)->dy , (nn)->dz = (oo)->dz , \
00177       (nn)->dt = (oo)->dt , (nn)->du = (oo)->du , (nn)->dv = (oo)->dv , \
00178       (nn)->dw = (oo)->dw ,                                             \
00179       (nn)->xo = (oo)->xo , (nn)->yo = (oo)->yo , (nn)->zo = (oo)->zo , \
00180       (nn)->to = (oo)->to , (nn)->uo = (oo)->uo , (nn)->vo = (oo)->vo , \
00181       (nn)->wo = (oo)->wo ,                                             \
00182       strcpy((nn)->xlab,(oo)->xlab) , strcpy((nn)->ylab,(oo)->ylab) ,   \
00183       strcpy((nn)->zlab,(oo)->zlab) , strcpy((nn)->tlab,(oo)->tlab) ,   \
00184       strcpy((nn)->ulab,(oo)->ulab) , strcpy((nn)->vlab,(oo)->vlab) ,   \
00185       strcpy((nn)->wlab,(oo)->wlab) ,                                   \
00186       mri_add_name( (oo)->name , (nn) ) )
00187 #else
00188 #  define MRI_COPY_AUX(nn,oo)                                           \
00189     ( (nn)->dx = (oo)->dx , (nn)->dy = (oo)->dy , (nn)->dz = (oo)->dz , \
00190       (nn)->dt = (oo)->dt , (nn)->du = (oo)->du , (nn)->dv = (oo)->dv , \
00191       (nn)->dw = (oo)->dw ,                                             \
00192       (nn)->xo = (oo)->xo , (nn)->yo = (oo)->yo , (nn)->zo = (oo)->zo , \
00193       (nn)->to = (oo)->to , (nn)->uo = (oo)->uo , (nn)->vo = (oo)->vo , \
00194       (nn)->wo = (oo)->wo ,                                             \
00195       mri_add_name( (oo)->name , (nn) ) )
00196 #endif
00197 
00198 
00199 #define MRI_IS_1D(iq)  ((iq)->ny == 1)
00200 
00201 
00202 #define MRI_IS_2D(iq)  ((iq)->ny > 1 && (iq)->nz == 1)
00203 
00204 
00205 #define MRI_IS_3D(iq)  ((iq)->nz > 1 && (iq)->nt == 1)
00206 
00207 
00208 #define MRI_IS_4D(iq)  ((iq)->nt > 1 && (iq)->nu == 1)
00209 
00210 
00211 #define MRI_DIMENSIONALITY(iq)                     \
00212  ( ((iq)->ny == 1) ? 1 : ((iq)->nz == 1) ? 2 :     \
00213    ((iq)->nt == 1) ? 3 : ((iq)->nu == 1) ? 4 :     \
00214    ((iq)->nv == 1) ? 5 : ((iq)->nw == 1) ? 6 : 7 )
00215 
00216 #define MRI_BYTE_PTR(iq)    ((iq)->im.byte_data)
00217 #define MRI_SHORT_PTR(iq)   ((iq)->im.short_data)
00218 #define MRI_INT_PTR(iq)     ((iq)->im.int_data)
00219 #define MRI_FLOAT_PTR(iq)   ((iq)->im.float_data)
00220 #define MRI_DOUBLE_PTR(iq)  ((iq)->im.double_data)
00221 #define MRI_COMPLEX_PTR(iq) ((iq)->im.complex_data)
00222 #define MRI_RGB_PTR(iq)     ((iq)->im.rgb_data)
00223 #define MRI_RGBA_PTR(iq)    ((iq)->im.rgba_data)
00224 
00225 #define MRI_BYTE_2D(iq,ix,jy)    MRI_BYTE_PTR(iq)[(ix)+(jy)*(iq)->nx]
00226 #define MRI_SHORT_2D(iq,ix,jy)   MRI_SHORT_PTR(iq)[(ix)+(jy)*(iq)->nx]
00227 #define MRI_INT_2D(iq,ix,jy)     MRI_INT_PTR(iq)[(ix)+(jy)*(iq)->nx]
00228 #define MRI_FLOAT_2D(iq,ix,jy)   MRI_FLOAT_PTR(iq)[(ix)+(jy)*(iq)->nx]
00229 #define MRI_DOUBLE_2D(iq,ix,jy)  MRI_DOUBLE_PTR(iq)[(ix)+(jy)*(iq)->nx]
00230 #define MRI_COMPLEX_2D(iq,ix,jy) MRI_COMPLEX_PTR(iq)[(ix)+(jy)*(iq)->nx]
00231 
00232 #endif