src/dicom.h

00001 /*************************
00002  * libdicom by Tony Voet *
00003  *************************/
00004 
00005 #ifndef __LIBDICOM__
00006 
00007 #include <stdio.h>
00008 
00009 /* change code for MedCon */
00010 #define MEDCON_INTEGRATED 1
00011 
00012 /* eNlf: BEGIN - add macro for safe freeing of pointers */
00013 #define eNlfSafeFree(p)          { if (p != NULL) free(p); p=NULL; }
00014 /* eNlf: END   - add macro for safe freeing of pointers */
00015 
00016 #define S8      char
00017 #define S16     short
00018 #define S32     int
00019 
00020 #define U8      unsigned S8
00021 #define U16     unsigned S16
00022 #define U32     unsigned S32
00023 
00024 /*******
00025  * log *
00026  *******/
00027 
00028 typedef enum
00029 {
00030   EMERGENCY,
00031   ALERT,
00032   CRITICAL,
00033   ERROR,
00034   WARNING,
00035   NOTICE,
00036   INFO,
00037   DEBUG
00038 }
00039 CONDITION;
00040 
00041 CONDITION dicom_log_level;
00042 
00043 void    dicom_log_name(char *);
00044 int     dicom_log_open(const char *);
00045 void    dicom_log(CONDITION,const char *);
00046 int     dicom_log_close(void);
00047 
00048 char* dicom_log_string;
00049 
00050 /*********
00051  * basic *
00052  *********/
00053 
00054 typedef struct
00055 {
00056   U16 group,element;
00057 }
00058 TAG;
00059 
00060 typedef enum
00061 {
00062   AE=('A'<<8)|'E',
00063   AS=('A'<<8)|'S',
00064   AT=('A'<<8)|'T',
00065   CS=('C'<<8)|'S',
00066   DA=('D'<<8)|'A',
00067   DS=('D'<<8)|'S',
00068   DT=('D'<<8)|'T',
00069   FL=('F'<<8)|'L',
00070   FD=('F'<<8)|'D',
00071   IS=('I'<<8)|'S',
00072   LO=('L'<<8)|'O',
00073   LT=('L'<<8)|'T',
00074   OB=('O'<<8)|'B',
00075   OW=('O'<<8)|'W',
00076   PN=('P'<<8)|'N',
00077   SH=('S'<<8)|'H',
00078   SL=('S'<<8)|'L',
00079   SQ=('S'<<8)|'Q',
00080   SS=('S'<<8)|'S',
00081   ST=('S'<<8)|'T',
00082   TM=('T'<<8)|'M',
00083   UI=('U'<<8)|'I',
00084   UL=('U'<<8)|'L',
00085   US=('U'<<8)|'S',
00086   UN=('U'<<8)|'N',
00087   UT=('U'<<8)|'T',
00088 /* special tag (choices) */
00089   ox=('o'<<8)|'x',
00090 }
00091 VR;
00092 
00093 typedef struct
00094 {
00095   U16   group,element;
00096   VR    vr;
00097   U32   length;
00098 
00099   union
00100   {
00101     TAG         *AT;
00102     double      *FD;
00103     float       *FL;
00104     U32         *UL;
00105     S32         *SL;
00106     U16         *OW,*US;
00107     S16         *SS;
00108     U8          *OB;
00109     char        **AE,**AS,**CS,**DA,**DS,**DT,**IS,
00110                 **LO,*LT,**PN,**SH,*ST,**TM,**UI, *UT;
00111     void        *SQ,*UN;
00112   }
00113   value;
00114 
00115   U32   vm;
00116   int   encapsulated;
00117   U8    sequence;
00118 }
00119 ELEMENT;
00120 
00121 extern char dicom_version[],**dicom_transfer_syntax;
00122 
00123 #if MEDCON_INTEGRATED
00124 void    dicom_init(FILE *fp);
00125 #endif
00126 int     dicom_open(const char *);
00127 ELEMENT *dicom_element(void);
00128 int     dicom_skip(void);
00129 int     dicom_load(VR);
00130 void    dicom_clean(void);
00131 int     dicom_close(void);
00132 
00133 /* eNlf: BEGIN -- changes for integration in MedCon */
00134 int mdc_dicom_load(VR);
00135 /* eNlf: END   -- changes for integration in MedCon */
00136 
00137 /**************
00138  * dictionary *
00139  **************/
00140 
00141 typedef enum
00142 {
00143   EVEN,
00144   ODD,
00145   ANY
00146 }
00147 MATCH;
00148 
00149 typedef struct
00150 {
00151   U16   group,group_last;
00152   MATCH group_match;
00153   U16   element,element_last;
00154   MATCH element_match;
00155   VR    vr;
00156   char  *description;
00157 }
00158 DICTIONARY;
00159 
00160 DICTIONARY *dicom_query(ELEMENT *);
00161 DICTIONARY *dicom_private(DICTIONARY *,ELEMENT *);
00162 
00163 /**********
00164  * single *
00165  **********/
00166 
00167 typedef struct
00168 {
00169   U16 size,bit;
00170 
00171   union
00172   {
00173     U16 u16;
00174     S16 s16;
00175   }
00176   threshold;
00177 
00178   union
00179   {
00180     U16 *u16;
00181     S16 *s16;
00182   }
00183   data;
00184 }
00185 CLUT;
00186 
00187 typedef struct
00188 {
00189   enum
00190   {
00191     MONOCHROME2,
00192     MONOCHROME1,
00193     PALETTE_COLOR,
00194     RGB,
00195     HSV,
00196     ARGB,
00197     CMYK,
00198     UNKNOWN
00199   }
00200   photometric;
00201 
00202   int   frames;
00203   U16   w,h,samples,alloc,bit,high,sign,planar;
00204   CLUT  clut[3];
00205   void  *data;
00206 }
00207 SINGLE;
00208 
00209 SINGLE  *dicom_single(void);
00210 void    dicom_single_free(void);
00211 
00212 /*******
00213  * bit *
00214  *******/
00215 
00216 void    dicom_bit(void *);
00217 
00218 void    dicom_8_skip(int);
00219 void    dicom_16_skip(int);
00220 void    dicom_32_skip(int);
00221 
00222 U32     dicom_8_read(int);
00223 U32     dicom_16_read(int);
00224 U32     dicom_32_read(int);
00225 
00226 /*********
00227  * image *
00228  *********/
00229 
00230 typedef struct
00231 {
00232   int   rgb;
00233   U16   frames,w,h;
00234 
00235   union
00236   {
00237     U16 *gray;
00238     U8  *rgb;
00239   }
00240   data;
00241 }
00242 IMAGE;
00243 
00244 IMAGE   *dicom_new(int,U16,U16,U16);
00245 int     dicom_read(const char *,IMAGE **,int *,int);
00246 void    dicom_free(IMAGE *,int);
00247 
00248 int     dicom_write(const char *,const IMAGE *);
00249 /* eNlf: BEGIN - comment out unwanted stuff */
00250 /* int  dicom_write_ascii(const char *,const IMAGE *,int); */
00251 /* int  dicom_write_jpeg(const char *,const IMAGE *,int);  */
00252 /* int  dicom_write_eps(const char *,const IMAGE *);       */
00253 /* eNlf: END   - comment out unwanted stuff */          
00254 /*************
00255  * transform *
00256  *************/
00257 
00258 int     dicom_alloc(SINGLE *);
00259 int     dicom_sign(SINGLE *);
00260 int     dicom_planar(SINGLE *);
00261 int     dicom_shift(SINGLE *);
00262 
00263 IMAGE   *dicom_transform(SINGLE *,int);
00264 
00265 /********
00266  * zoom *
00267  ********/
00268 
00269 IMAGE *dicom_zoom(const IMAGE *,int,int,int);
00270 
00271 /***********
00272  * process *
00273  ***********/
00274 
00275 void    dicom_max(IMAGE *);
00276 void    dicom_invert(IMAGE *);
00277 void    dicom_voi(IMAGE *,U16,U16);
00278 void    dicom_gray(IMAGE *);
00279 
00280 void    dicom_hsv(U16,U16,U16,U8 *);
00281 IMAGE   *dicom_merge(const IMAGE *,const IMAGE *,U16);
00282 
00283 #define __LIBDICOM__
00284 #endif

Generated on Sat Nov 15 23:24:49 2008 for Crystal Image by  doxygen 1.5.3