Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

diutils.h

00001 /*
00002  *
00003  *  Copyright (C) 1996-2003, OFFIS
00004  *
00005  *  This software and supporting documentation were developed by
00006  *
00007  *    Kuratorium OFFIS e.V.
00008  *    Healthcare Information and Communication Systems
00009  *    Escherweg 2
00010  *    D-26121 Oldenburg, Germany
00011  *
00012  *  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  AND OFFIS MAKES NO  WARRANTY
00013  *  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE,  ITS  MERCHANTABILITY  OR
00014  *  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES  OR
00015  *  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
00016  *  PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
00017  *
00018  *  Module:  dcmimgle
00019  *
00020  *  Author:  Joerg Riesmeier
00021  *
00022  *  Purpose: Utilities (Header)
00023  *
00024  *  Last Update:      $Author: joergr $
00025  *  Update Date:      $Date: 2003/12/23 15:53:22 $
00026  *  CVS/RCS Revision: $Revision: 1.25 $
00027  *  Status:           $State: Exp $
00028  *
00029  *  CVS/RCS Log at end of file
00030  *
00031  */
00032 
00033 
00034 #ifndef DIUTILS_H
00035 #define DIUTILS_H
00036 
00037 #include "osconfig.h"
00038 #include "dctypes.h"
00039 #include "ofglobal.h"
00040 #include "ofcast.h"
00041 
00042 #define INCLUDE_CSTDLIB
00043 #define INCLUDE_CSTDIO
00044 #include "ofstdinc.h"
00045 
00046 BEGIN_EXTERN_C
00047 #ifdef HAVE_LIBC_H
00048 #include <libc.h>
00049 #endif
00050 END_EXTERN_C
00051 
00052 
00053 /*---------------------*
00054  *  const definitions  *
00055  *---------------------*/
00056 
00061 
00063 const unsigned long CIF_AcrNemaCompatibility         = 0x0000001;
00064 
00066 const unsigned long CIF_WrongPaletteAttributeTags    = 0x0000002;
00067 
00069 const unsigned long CIF_MayDetachPixelData           = 0x0000004;
00070 
00072 const unsigned long CIF_UsePresentationState         = 0x0000008;
00073 
00075 const unsigned long CIF_KeepYCbCrColorModel          = 0x0000010;
00076 
00078 const unsigned long CIF_TakeOverExternalDataset      = 0x0000020;
00079 
00081 const unsigned long CIF_IgnoreModalityTransformation = 0x0000040;
00082 
00084 const unsigned long CIF_IgnoreModalityLutBitDepth    = 0x0000080;
00086 
00087 
00088 // / true color color mode (for monochrome images only)
00089 const int MI_PastelColor = -1;
00090 
00091 
00092 /*--------------------*
00093  *  type definitions  *
00094  *--------------------*/
00095 
00098 enum EP_Interpretation
00099 {
00101     EPI_Unknown,
00103     EPI_Monochrome1,
00105     EPI_Monochrome2,
00107     EPI_PaletteColor,
00109     EPI_RGB,
00111     EPI_HSV,
00113     EPI_ARGB,
00115     EPI_CMYK,
00117     EPI_YBR_Full,
00119     EPI_YBR_Full_422,
00121     EPI_YBR_Partial_422
00122 };
00123 
00124 
00127 struct SP_Interpretation
00128 {
00130     const char *Name;
00132     EP_Interpretation Type;
00133 };
00134 
00135 
00138 struct SB_BitmapFileHeader
00139 {
00141     char bfType[2];
00143     Uint32 bfSize;
00145     Uint16 bfReserved1;
00147     Uint16 bfReserved2;
00149     Uint32 bfOffBits;
00150 };
00151 
00152 
00155 struct SB_BitmapInfoHeader
00156 {
00158     Uint32 biSize;
00160     Sint32 biWidth;
00162     Sint32 biHeight;
00164     Uint16 biPlanes;
00166     Uint16 biBitCount;
00168     Uint32 biCompression;
00170     Uint32 biSizeImage;
00172     Sint32 biXPelsPerMeter;
00174     Sint32 biYPelsPerMeter;
00176     Uint32 biClrUsed;
00178     Uint32 biClrImportant;
00179 };
00180 
00181 
00184 enum EP_Representation
00185 {
00187     EPR_Uint8, EPR_MinUnsigned = EPR_Uint8,
00189     EPR_Sint8, EPR_MinSigned = EPR_Sint8,
00191     EPR_Uint16,
00193     EPR_Sint16,
00195     EPR_Uint32, EPR_MaxUnsigned = EPR_Uint32,
00197     EPR_Sint32, EPR_MaxSigned = EPR_Sint32
00198 };
00199 
00200 
00203 enum EI_Status
00204 {
00206     EIS_Normal,
00208     EIS_NoDataDictionary,
00210     EIS_InvalidDocument,
00212     EIS_MissingAttribute,
00214     EIS_InvalidValue,
00216     EIS_NotSupportedValue,
00218     EIS_MemoryFailure,
00220     EIS_InvalidImage,
00222     EIS_OtherError
00223 };
00224 
00225 
00229 enum EM_Overlay
00230 {
00232     EMO_Default,
00234     EMO_Replace,
00236     EMO_Graphic = EMO_Replace,
00238     EMO_ThresholdReplace,
00240     EMO_Complement,
00242     EMO_RegionOfInterest,
00244     EMO_BitmapShutter
00245 };
00246 
00247 
00250 enum ES_PresentationLut
00251 {
00253     ESP_Default,
00255     ESP_Identity,
00257     ESP_Inverse,
00259     ESP_LinOD
00260 };
00261 
00262 
00265 enum EP_Polarity
00266 {
00268     EPP_Normal,
00270     EPP_Reverse
00271 };
00272 
00273 
00274 /*----------------------------*
00275  *  constant initializations  *
00276  *----------------------------*/
00277 
00278 const SP_Interpretation PhotometricInterpretationNames[] =
00279 {
00280     {"MONOCHROME1",   EPI_Monochrome1},
00281     {"MONOCHROME2",   EPI_Monochrome2},
00282     {"PALETTECOLOR",  EPI_PaletteColor},        // space deleted to simplify detection
00283     {"RGB",           EPI_RGB},
00284     {"HSV",           EPI_HSV},
00285     {"ARGB",          EPI_ARGB},
00286     {"CMYK",          EPI_CMYK},
00287     {"YBRFULL",       EPI_YBR_Full},            // underscore deleted to simplify detection
00288     {"YBRFULL422",    EPI_YBR_Full_422},        // underscores deleted to simplify detection
00289     {"YBRPARTIAL422", EPI_YBR_Partial_422},     // underscores deleted to simplify detection
00290     {NULL,            EPI_Unknown}
00291 };
00292 
00293 
00294 /*---------------------*
00295  *  macro definitions  *
00296  *---------------------*/
00297 
00298 #define MAX_UINT Uint32
00299 #define MAX_SINT Sint32
00300 
00301 #define MAX_BITS 32
00302 #define MAX_RAWPPM_BITS 8
00303 #define MAX_INTERPOLATION_BITS 16
00304 
00305 #define bitsof(expr) (sizeof(expr) << 3)
00306 
00307 
00308 /*----------------------*
00309  *  class declarations  *
00310  *----------------------*/
00311 
00315 class DicomImageClass
00316 {
00317 
00318  public:
00319 
00327     static inline unsigned long maxval(const int mv_bits,
00328                                        const unsigned long mv_pos = 1)
00329     {
00330         return (mv_bits < MAX_BITS) ? (OFstatic_cast(unsigned long, 1) << mv_bits) - mv_pos : OFstatic_cast(unsigned long, -1);
00331     }
00332 
00340     static inline unsigned int tobits(unsigned long tb_value,
00341                                       const unsigned long tb_pos = 1)
00342     {
00343         if (tb_value > 0)
00344             tb_value -= tb_pos;
00345         register unsigned int tb_bits = 0;
00346         while (tb_value > 0)
00347         {
00348             ++tb_bits;
00349             tb_value >>= 1;
00350         }
00351         return tb_bits;
00352     }
00353 
00361     static EP_Representation determineRepresentation(double minvalue,
00362                                                      double maxvalue);
00363 
00368     static void setDebugLevel(const int level)
00369     {
00370         DebugLevel.set(level);
00371     }
00372 
00377     static int getDebugLevel()
00378     {
00379         return DebugLevel.get();
00380     }
00381 
00388     static int checkDebugLevel(const int level)
00389     {
00390         return DebugLevel.get() & level;
00391     }
00392 
00393 
00395     static const int DL_NoMessages;
00397     static const int DL_Errors;
00399     static const int DL_Warnings;
00401     static const int DL_Informationals;
00403     static const int DL_DebugMessages;
00404 
00405 
00406   private:
00407 
00409     static OFGlobal<int> DebugLevel;
00410 };
00411 
00412 
00413 #endif
00414 
00415 
00416 /*
00417  *
00418  * CVS/RCS Log:
00419  * $Log: diutils.h,v $
00420  * Revision 1.25  2003/12/23 15:53:22  joergr
00421  * Replaced post-increment/decrement operators by pre-increment/decrement
00422  * operators where appropriate (e.g. 'i++' by '++i').
00423  *
00424  * Revision 1.24  2003/12/17 16:17:29  joergr
00425  * Added new compatibility flag that allows to ignore the third value of LUT
00426  * descriptors and to determine the bits per table entry automatically.
00427  *
00428  * Revision 1.23  2003/12/08 18:49:54  joergr
00429  * Adapted type casts to new-style typecast operators defined in ofcast.h.
00430  * Removed leading underscore characters from preprocessor symbols (reserved
00431  * symbols). Updated copyright header.
00432  *
00433  * Revision 1.22  2003/05/20 09:19:51  joergr
00434  * Added new configuration/compatibility flag that allows to ignore the
00435  * modality transform stored in the dataset.
00436  *
00437  * Revision 1.21  2002/11/27 14:08:08  meichel
00438  * Adapted module dcmimgle to use of new header file ofstdinc.h
00439  *
00440  * Revision 1.20  2002/06/26 16:08:14  joergr
00441  * Added configuration flag that enables the DicomImage class to take the
00442  * responsibility of an external DICOM dataset (i.e. delete it on destruction).
00443  *
00444  * Revision 1.19  2001/11/09 16:25:59  joergr
00445  * Added support for Window BMP file format.
00446  *
00447  * Revision 1.18  2001/09/28 13:11:00  joergr
00448  * Added new flag (CIF_KeepYCbCrColorModel) which avoids conversion of YCbCr
00449  * color models to RGB.
00450  *
00451  * Revision 1.17  2001/06/01 15:49:52  meichel
00452  * Updated copyright header
00453  *
00454  * Revision 1.16  2000/07/07 13:40:31  joergr
00455  * Added support for LIN OD presentation LUT shape.
00456  *
00457  * Revision 1.15  2000/06/07 14:30:28  joergr
00458  * Added method to set the image polarity (normal, reverse).
00459  *
00460  * Revision 1.14  2000/04/28 12:32:33  joergr
00461  * DebugLevel - global for the module - now derived from OFGlobal (MF-safe).
00462  *
00463  * Revision 1.13  2000/03/08 16:24:25  meichel
00464  * Updated copyright header.
00465  *
00466  * Revision 1.12  2000/02/23 15:12:16  meichel
00467  * Corrected macro for Borland C++ Builder 4 workaround.
00468  *
00469  * Revision 1.11  2000/02/01 10:52:38  meichel
00470  * Avoiding to include <stdlib.h> as extern "C" on Borland C++ Builder 4,
00471  *   workaround for bug in compiler header files.
00472  *
00473  * Revision 1.10  1999/09/17 13:08:13  joergr
00474  * Added/changed/completed DOC++ style comments in the header files.
00475  *
00476  * Revision 1.9  1999/07/23 14:16:16  joergr
00477  * Added flag to avoid color space conversion for color images (not yet
00478  * implemented).
00479  *
00480  * Revision 1.8  1999/04/30 16:33:19  meichel
00481  * Now including stdio.h in diutils.h, required on SunOS
00482  *
00483  * Revision 1.7  1999/04/28 14:55:41  joergr
00484  * Added experimental support to create grayscale images with more than 256
00485  * shades of gray to be displayed on a consumer monitor (use pastel colors).
00486  *
00487  * Revision 1.6  1999/03/24 17:20:28  joergr
00488  * Added/Modified comments and formatting.
00489  *
00490  * Revision 1.5  1999/02/03 17:36:06  joergr
00491  * Moved global functions maxval() and determineRepresentation() to class
00492  * DicomImageClass (as static methods).
00493  * Added BEGIN_EXTERN_C and END_EXTERN_C to some C includes.
00494  *
00495  * Revision 1.4  1999/01/20 15:13:12  joergr
00496  * Added new overlay plane mode for bitmap shutters.
00497  *
00498  * Revision 1.3  1998/12/23 11:38:08  joergr
00499  * Introduced new overlay mode item EMO_Graphic (= EMO_Replace).
00500  *
00501  * Revision 1.2  1998/12/16 16:40:15  joergr
00502  * Some layouting.
00503  *
00504  * Revision 1.1  1998/11/27 15:51:45  joergr
00505  * Added copyright message.
00506  * Introduced global debug level for dcmimage module to control error output.
00507  * Moved type definitions to diutils.h.
00508  * Added methods to support presentation LUTs and shapes.
00509  * Introduced configuration flags to adjust behaviour in different cases.
00510  *
00511  * Revision 1.5  1998/06/25 08:50:10  joergr
00512  * Added compatibility mode to support ACR-NEMA images and wrong
00513  * palette attribute tags.
00514  *
00515  * Revision 1.4  1998/05/11 14:53:30  joergr
00516  * Added CVS/RCS header to each file.
00517  *
00518  *
00519  */


Generated on 26 Apr 2005 for OFFIS DCMTK Version 3.5.3 by Doxygen 1.4.2