00001
00002
00003
00004
00005 #ifndef __LIBDICOM__
00006
00007 #include <stdio.h>
00008
00009
00010 #define MEDCON_INTEGRATED 1
00011
00012
00013 #define eNlfSafeFree(p) { if (p != NULL) free(p); p=NULL; }
00014
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
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
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
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
00134 int mdc_dicom_load(VR);
00135
00136
00137
00138
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
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
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
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
00250
00251
00252
00253
00254
00255
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
00267
00268
00269 IMAGE *dicom_zoom(const IMAGE *,int,int,int);
00270
00271
00272
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