00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef DIUTILS_H
00031 #define DIUTILS_H
00032
00033 #include "dcmtk/config/osconfig.h"
00034
00035 #include "dcmtk/ofstd/oftypes.h"
00036 #include "dcmtk/ofstd/ofcast.h"
00037
00038 #include "dcmtk/oflog/oflog.h"
00039
00040 OFLogger DCM_dcmimgleGetLogger();
00041
00042 #define DCMIMGLE_TRACE(msg) OFLOG_TRACE(DCM_dcmimgleGetLogger(), msg)
00043 #define DCMIMGLE_DEBUG(msg) OFLOG_DEBUG(DCM_dcmimgleGetLogger(), msg)
00044 #define DCMIMGLE_INFO(msg) OFLOG_INFO(DCM_dcmimgleGetLogger(), msg)
00045 #define DCMIMGLE_WARN(msg) OFLOG_WARN(DCM_dcmimgleGetLogger(), msg)
00046 #define DCMIMGLE_ERROR(msg) OFLOG_ERROR(DCM_dcmimgleGetLogger(), msg)
00047 #define DCMIMGLE_FATAL(msg) OFLOG_FATAL(DCM_dcmimgleGetLogger(), msg)
00048
00049
00050
00051
00052
00053
00058
00060 const unsigned long CIF_AcrNemaCompatibility = 0x0000001;
00061
00063 const unsigned long CIF_WrongPaletteAttributeTags = 0x0000002;
00064
00066 const unsigned long CIF_MayDetachPixelData = 0x0000004;
00067
00069 const unsigned long CIF_UsePresentationState = 0x0000008;
00070
00072 const unsigned long CIF_KeepYCbCrColorModel = 0x0000010;
00073
00075 const unsigned long CIF_TakeOverExternalDataset = 0x0000020;
00076
00078 const unsigned long CIF_IgnoreModalityTransformation = 0x0000040;
00079
00081 const unsigned long CIF_IgnoreModalityLutBitDepth = 0x0000080;
00082
00084 const unsigned long CIF_CheckLutBitDepth = 0x0000100;
00085
00087 const unsigned long CIF_UseAbsolutePixelRange = 0x0000200;
00088
00090 const unsigned long CIF_UsePartialAccessToPixelData = 0x0000400;
00091
00093 const unsigned long CIF_DecompressCompletePixelData = 0x0000800;
00094
00096 const unsigned long CIF_NeverAccessEmbeddedOverlays = 0x0001000;
00098
00099
00100
00101 const int MI_PastelColor = -1;
00102
00103
00104
00105
00106
00107
00110 enum EP_Interpretation
00111 {
00113 EPI_Unknown,
00114
00115 EPI_Missing,
00117 EPI_Monochrome1,
00119 EPI_Monochrome2,
00121 EPI_PaletteColor,
00123 EPI_RGB,
00125 EPI_HSV,
00127 EPI_ARGB,
00129 EPI_CMYK,
00131 EPI_YBR_Full,
00133 EPI_YBR_Full_422,
00135 EPI_YBR_Partial_422
00136 };
00137
00138
00141 struct SP_Interpretation
00142 {
00144 const char *Name;
00146 const char *DefinedTerm;
00148 EP_Interpretation Type;
00149 };
00150
00151
00154 struct SB_BitmapFileHeader
00155 {
00157 char bfType[2];
00159 Uint32 bfSize;
00161 Uint16 bfReserved1;
00163 Uint16 bfReserved2;
00165 Uint32 bfOffBits;
00166 };
00167
00168
00171 struct SB_BitmapInfoHeader
00172 {
00174 Uint32 biSize;
00176 Sint32 biWidth;
00178 Sint32 biHeight;
00180 Uint16 biPlanes;
00182 Uint16 biBitCount;
00184 Uint32 biCompression;
00186 Uint32 biSizeImage;
00188 Sint32 biXPelsPerMeter;
00190 Sint32 biYPelsPerMeter;
00192 Uint32 biClrUsed;
00194 Uint32 biClrImportant;
00195 };
00196
00197
00200 enum EP_Representation
00201 {
00203 EPR_Uint8, EPR_MinUnsigned = EPR_Uint8,
00205 EPR_Sint8, EPR_MinSigned = EPR_Sint8,
00207 EPR_Uint16,
00209 EPR_Sint16,
00211 EPR_Uint32, EPR_MaxUnsigned = EPR_Uint32,
00213 EPR_Sint32, EPR_MaxSigned = EPR_Sint32
00214 };
00215
00216
00219 enum EI_Status
00220 {
00222 EIS_Normal,
00224 EIS_NoDataDictionary,
00226 EIS_InvalidDocument,
00228 EIS_MissingAttribute,
00230 EIS_InvalidValue,
00232 EIS_NotSupportedValue,
00234 EIS_MemoryFailure,
00236 EIS_InvalidImage,
00238 EIS_OtherError
00239 };
00240
00241
00245 enum EM_Overlay
00246 {
00248 EMO_Default,
00250 EMO_Replace,
00252 EMO_Graphic = EMO_Replace,
00254 EMO_ThresholdReplace,
00256 EMO_Complement,
00258 EMO_InvertBitmap,
00260 EMO_RegionOfInterest,
00262 EMO_BitmapShutter
00263 };
00264
00265
00268 enum EF_VoiLutFunction
00269 {
00271 EFV_Default,
00273 EFV_Linear,
00275 EFV_Sigmoid
00276 };
00277
00278
00281 enum ES_PresentationLut
00282 {
00284 ESP_Default,
00286 ESP_Identity,
00288 ESP_Inverse,
00290 ESP_LinOD
00291 };
00292
00293
00296 enum EP_Polarity
00297 {
00299 EPP_Normal,
00301 EPP_Reverse
00302 };
00303
00304
00308 enum EL_BitsPerTableEntry
00309 {
00311 ELM_UseValue,
00313 ELM_IgnoreValue,
00315 ELM_CheckValue
00316 };
00317
00318
00319
00320
00321
00322
00323 const SP_Interpretation PhotometricInterpretationNames[] =
00324 {
00325 {"MONOCHROME1", "MONOCHROME1", EPI_Monochrome1},
00326 {"MONOCHROME2", "MONOCHROME2", EPI_Monochrome2},
00327 {"PALETTECOLOR", "PALETTE COLOR", EPI_PaletteColor},
00328 {"RGB", "RGB", EPI_RGB},
00329 {"HSV", "HSV", EPI_HSV},
00330 {"ARGB", "ARGB", EPI_ARGB},
00331 {"CMYK", "CMYK", EPI_CMYK},
00332 {"YBRFULL", "YBR_FULL", EPI_YBR_Full},
00333 {"YBRFULL422", "YBR_FULL_422", EPI_YBR_Full_422},
00334 {"YBRPARTIAL422", "YBR_PARTIAL_422", EPI_YBR_Partial_422},
00335 {NULL, NULL, EPI_Unknown}
00336 };
00337
00338
00339
00340
00341
00342
00343 #define MAX_UINT Uint32
00344 #define MAX_SINT Sint32
00345
00346 #define MAX_BITS 32
00347 #define MAX_BITS_TYPE Uint32
00348 #define MAX_RAWPPM_BITS 8
00349 #define MAX_INTERPOLATION_BITS 16
00350
00351 #define bitsof(expr) (sizeof(expr) << 3)
00352
00353
00354
00355
00356
00357
00361 class DicomImageClass
00362 {
00363
00364 public:
00365
00373 static inline unsigned long maxval(const int mv_bits,
00374 const unsigned long mv_pos = 1)
00375 {
00376 return (mv_bits < MAX_BITS) ?
00377 (OFstatic_cast(unsigned long, 1) << mv_bits) - mv_pos : OFstatic_cast(MAX_BITS_TYPE, -1);
00378 }
00379
00387 static inline unsigned int tobits(unsigned long tb_value,
00388 const unsigned long tb_pos = 1)
00389 {
00390 if (tb_value > 0)
00391 tb_value -= tb_pos;
00392 register unsigned int tb_bits = 0;
00393 while (tb_value > 0)
00394 {
00395 ++tb_bits;
00396 tb_value >>= 1;
00397 }
00398 return tb_bits;
00399 }
00400
00408 static unsigned int rangeToBits(double minvalue,
00409 double maxvalue);
00410
00417 static int isRepresentationSigned(EP_Representation repres);
00418
00425 static unsigned int getRepresentationBits(EP_Representation repres);
00426
00434 static EP_Representation determineRepresentation(double minvalue,
00435 double maxvalue);
00436
00437 };
00438
00439
00440 #endif
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604