OFFIS DCMTK  Version 3.6.0
dimoimg.h
1 /*
2  *
3  * Copyright (C) 1996-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmimgle
15  *
16  * Author: Joerg Riesmeier
17  *
18  * Purpose: DicomMonochromeImage (Header)
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:16:26 $
22  * CVS/RCS Revision: $Revision: 1.57 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DIMOIMG_H
31 #define DIMOIMG_H
32 
33 #include "dcmtk/config/osconfig.h"
34 
35 #include "dcmtk/ofstd/ofcast.h"
36 
37 #include "dcmtk/dcmimgle/diimage.h"
38 #include "dcmtk/dcmimgle/dimopx.h"
39 #include "dcmtk/dcmimgle/dimoopx.h"
40 #include "dcmtk/dcmimgle/didispfn.h"
41 
42 
43 /*------------------------*
44  * forward declarations *
45  *------------------------*/
46 
47 class DiColorImage;
48 
49 
50 /*---------------------*
51  * class declaration *
52  *---------------------*/
53 
57  : public DiImage
58 {
59 
60  public:
61 
67  DiMonoImage(const DiDocument *docu,
68  const EI_Status status);
69 
77  DiMonoImage(const DiDocument *docu,
78  const EI_Status status,
79  const double slope,
80  const double intercept);
81 
90  DiMonoImage(const DiDocument *docu,
91  const EI_Status status,
92  const DcmUnsignedShort &data,
93  const DcmUnsignedShort &descriptor,
94  const DcmLongString *explanation);
95 
98  virtual ~DiMonoImage();
99 
106  virtual int processNextFrames(const unsigned long fcount);
107 
119  int getMinMaxValues(double &min,
120  double &max,
121  const int mode) const;
122 
128  {
129  return DisplayFunction;
130  }
131 
139 
147  int setNoDisplayFunction();
148 
157 
164  inline int deleteDisplayLUT(const int bits)
165  {
166  return (DisplayFunction != NULL) ? DisplayFunction->deleteLookupTable(bits) : 0;
167  }
168 
175  inline int isValueUnused(const unsigned long value)
176  {
177  return (OutputData != NULL) ? OutputData->isUnused(value) : 0;
178  }
179 
191  int convertPValueToDDL(const Uint16 pvalue,
192  Uint16 &ddl,
193  const int bits);
194 
204  int setMinMaxWindow(const int idx = 1);
205 
220  int setRoiWindow(const unsigned long left_pos,
221  const unsigned long top_pos,
222  const unsigned long width,
223  const unsigned long height,
224  const unsigned long frame);
225 
233  int setHistogramWindow(const double thresh);
234 
242  int setWindow(const unsigned long pos = 0);
243 
255  int setWindow(const double center,
256  const double width,
257  const char *explanation = NULL);
258 
266  int getWindow(double &center,
267  double &width);
268 
273  inline unsigned long getWindowCount() const
274  {
275  return WindowCount;
276  }
277 
283  EF_VoiLutFunction getVoiLutFunction() const;
284 
294  int setVoiLutFunction(const EF_VoiLutFunction function);
295 
306  int setVoiLut(const DcmUnsignedShort &data,
307  const DcmUnsignedShort &descriptor,
308  const DcmLongString *explanation,
309  const EL_BitsPerTableEntry descripMode = ELM_UseValue);
310 
319  int setVoiLut(const unsigned long pos,
320  const EL_BitsPerTableEntry descripMode = ELM_UseValue);
321 
326  inline unsigned long getVoiLutCount() const
327  {
328  return VoiLutCount;
329  }
330 
335  inline const char *getVoiTransformationExplanation() const
336  {
337  return VoiExplanation.c_str();
338  }
339 
347  const char *getVoiWindowExplanation(const unsigned long pos,
348  OFString &explanation) const;
349 
357  const char *getVoiLutExplanation(const unsigned long pos,
358  OFString &explanation) const;
359 
364  inline const char *getModalityLutExplanation() const
365  {
366  return (InterData != NULL) ? InterData->getModalityLutExplanation() : OFstatic_cast(const char *, NULL);
367  }
368 
380  int setHardcopyParameters(const unsigned int min,
381  const unsigned int max,
382  const unsigned int reflect,
383  const unsigned int illumin);
384 
391  ES_PresentationLut getPresentationLutShape() const;
392 
404  int setPresentationLutShape(const ES_PresentationLut shape);
405 
416  int setPresentationLut(const DcmUnsignedShort &data,
417  const DcmUnsignedShort &descriptor,
418  const DcmLongString *explanation = NULL,
419  const EL_BitsPerTableEntry descripMode = ELM_UseValue);
420 
432  const DcmUnsignedShort &descriptor,
433  const EL_BitsPerTableEntry descripMode = ELM_UseValue);
434 
439  inline const char *getPresentationLutExplanation() const
440  {
441  return (PresLutData != NULL) ? PresLutData->getExplanation() : OFstatic_cast(const char *, NULL);
442  }
443 
460  int addOverlay(const unsigned int group,
461  const signed int left_pos,
462  const signed int top_pos,
463  const unsigned int columns,
464  const unsigned int rows,
465  const DcmOverlayData &data,
466  const DcmLongString &label,
467  const DcmLongString &description,
468  const EM_Overlay mode);
469 
474  int removeAllOverlays();
475 
482  inline DiOverlay *getOverlayPtr(const unsigned int idx)
483  {
484  return (idx < 2) ? Overlays[idx] : OFstatic_cast(DiOverlay *, NULL);
485  }
486 
492  {
493  return this;
494  }
495 
505  int flip(const int horz,
506  const int vert);
507 
516  int rotate(const int degree);
517 
528  virtual int getBits(const int bits = 0) const
529  {
530  return (((bits < 1) || (bits > MAX_BITS)) && (bits != MI_PastelColor)) ? BitsPerSample : bits;
531  }
532 
539  virtual unsigned long getOutputDataSize(const int bits = 0) const;
540 
550  virtual const void *getOutputData(const unsigned long frame,
551  const int bits,
552  const int planar = 0) = 0;
553 
565  virtual int getOutputData(void *buffer,
566  const unsigned long size,
567  const unsigned long frame,
568  const int bits,
569  const int planar = 0) = 0;
570 
578  const void *getOutputPlane(const int dummy) const;
579 
583  void deleteOutputData();
584 
602  const void *getOverlayData(const unsigned long frame,
603  const unsigned int plane,
604  unsigned int &left_pos,
605  unsigned int &top_pos,
606  unsigned int &width,
607  unsigned int &height,
608  EM_Overlay &mode,
609  const unsigned int idx,
610  const int bits = 8,
611  const Uint16 fore = 0xff,
612  const Uint16 back = 0x0);
613 
628  const void *getFullOverlayData(const unsigned long frame,
629  const unsigned int plane,
630  unsigned int &width,
631  unsigned int &height,
632  const unsigned int idx,
633  const int bits = 8,
634  const Uint16 fore = 0xff,
635  const Uint16 back = 0x0);
636 
640  void deleteOverlayData();
641 
658  unsigned long create6xxx3000OverlayData(Uint8 *&buffer,
659  const unsigned int plane,
660  unsigned int &width,
661  unsigned int &height,
662  unsigned long &frames,
663  const unsigned int idx = 0);
664 
669  const DiPixel *getInterData() const
670  {
671  return InterData;
672  }
673 
679  {
680  return InterData;
681  }
682 
695  unsigned long createDIB(void *&data,
696  const unsigned long size,
697  const unsigned long frame,
698  const int bits,
699  const int upsideDown,
700  const int padding = 1);
701 
711  unsigned long createAWTBitmap(void *&data,
712  const unsigned long frame,
713  const int bits);
714 
726  static void *createPackedBitmap(const void *buffer,
727  const unsigned long size,
728  const unsigned long count,
729  const int alloc,
730  const int stored);
731 
740  DiImage *createOutputImage(const unsigned long frame,
741  const int bits);
742 
752  int writeImageToDataset(DcmItem &dataset,
753  const int mode,
754  const int planar);
755 
765  int writePPM(STD_NAMESPACE ostream& stream,
766  const unsigned long frame,
767  const int bits);
768 
778  int writePPM(FILE *stream,
779  const unsigned long frame,
780  const int bits);
781 
790  int writeRawPPM(FILE *stream,
791  const unsigned long frame,
792  const int bits);
793 
802  int writeBMP(FILE *stream,
803  const unsigned long frame,
804  const int bits);
805 
806 
807  protected:
808 
815  DiMonoImage(const DiDocument *image,
816  const EI_Status status,
817  const char dummy);
818 
825  DiMonoImage(const DiMonoImage *image,
826  const unsigned long fstart,
827  const unsigned long fcount);
828 
838  DiMonoImage(const DiColorImage *image,
839  const double red,
840  const double green,
841  const double blue);
842 
862  DiMonoImage(const DiMonoImage *image,
863  const signed long left_pos,
864  const signed long top_pos,
865  const Uint16 src_cols,
866  const Uint16 src_rows,
867  const Uint16 dest_cols,
868  const Uint16 dest_rows,
869  const int interpolate,
870  const int aspect,
871  const Uint16 pvalue);
872 
879  DiMonoImage(const DiMonoImage *image,
880  const int horz,
881  const int vert);
882 
888  DiMonoImage(const DiMonoImage *image,
889  const int degree);
890 
899  DiMonoImage(const DiMonoImage *image,
900  DiMonoOutputPixel *pixel,
901  const unsigned long frame,
902  const int stored,
903  const int alloc);
904 
910  void Init(DiMonoModality *modality,
911  const OFBool reuse = OFFalse);
912 
917  void InitUint8(DiMonoModality *modality);
918 
923  void InitSint8(DiMonoModality *modality);
924 
929  void InitUint16(DiMonoModality *modality);
930 
935  void InitSint16(DiMonoModality *modality);
936 
941  void InitUint32(DiMonoModality *modality);
942 
947  void InitSint32(DiMonoModality *modality);
948 
953  int checkInterData(const int mode = 1);
954 
962  virtual void updateImagePixelModuleAttributes(DcmItem &dataset);
963 
976  const void *getData(void *buffer,
977  const unsigned long size,
978  const unsigned long frame,
979  int bits,
980  const int planar,
981  const int negative);
982 
994  void getDataUint8(void *buffer,
995  DiDisplayFunction *disp,
996  const int samples,
997  const unsigned long frame,
998  const int bits,
999  const Uint32 low,
1000  const Uint32 high);
1001 
1013  void getDataSint8(void *buffer,
1014  DiDisplayFunction *disp,
1015  const int samples,
1016  const unsigned long frame,
1017  const int bits,
1018  const Uint32 low,
1019  const Uint32 high);
1020 
1032  void getDataUint16(void *buffer,
1033  DiDisplayFunction *disp,
1034  const int samples,
1035  const unsigned long frame,
1036  const int bits,
1037  const Uint32 low,
1038  const Uint32 high);
1039 
1051  void getDataSint16(void *buffer,
1052  DiDisplayFunction *disp,
1053  const int samples,
1054  const unsigned long frame,
1055  const int bits,
1056  const Uint32 low,
1057  const Uint32 high);
1058 
1070  void getDataUint32(void *buffer,
1071  DiDisplayFunction *disp,
1072  const int samples,
1073  const unsigned long frame,
1074  const int bits,
1075  const Uint32 low,
1076  const Uint32 high);
1077 
1089  void getDataSint32(void *buffer,
1090  DiDisplayFunction *disp,
1091  const int samples,
1092  const unsigned long frame,
1093  const int bits,
1094  const Uint32 low,
1095  const Uint32 high);
1096 
1105  int createLinODPresentationLut(const unsigned long count, const int bits);
1106 
1110  double WindowWidth;
1112  unsigned long WindowCount;
1114  unsigned long VoiLutCount;
1115 
1118 
1122  EF_VoiLutFunction VoiLutFunction;
1124  ES_PresentationLut PresLutShape;
1125 
1127  unsigned int MinDensity;
1129  unsigned int MaxDensity;
1131  unsigned int Reflection;
1133  unsigned int Illumination;
1134 
1143 
1146 
1147 
1148  private:
1149 
1154 
1155  // --- declarations to avoid compiler warnings
1156 
1157  DiMonoImage(const DiMonoImage &);
1158  DiMonoImage &operator=(const DiMonoImage &);
1159 };
1160 
1161 
1162 #endif
1163 
1164 
1165 /*
1166  *
1167  * CVS/RCS Log:
1168  * $Log: dimoimg.h,v $
1169  * Revision 1.57 2010-10-14 13:16:26 joergr
1170  * Updated copyright header. Added reference to COPYRIGHT file.
1171  *
1172  * Revision 1.56 2010-10-05 15:24:02 joergr
1173  * Added preliminary support for VOI LUT function. Please note, however, that
1174  * the sigmoid transformation is not yet implemented.
1175  *
1176  * Revision 1.55 2010-07-21 13:08:56 joergr
1177  * Fixed memory leak when using processNextFrames(): DiOverlay object was
1178  * created multiple times.
1179  *
1180  * Revision 1.54 2010-03-01 09:08:47 uli
1181  * Removed some unnecessary include directives in the headers.
1182  *
1183  * Revision 1.53 2009-11-25 16:06:14 joergr
1184  * Adapted code for new approach to access individual frames of a DICOM image.
1185  *
1186  * Revision 1.52 2008-11-18 11:01:28 joergr
1187  * Fixed issue with incorrectly encoded overlay planes (wrong values for
1188  * OverlayBitsAllocated and OverlayBitPosition).
1189  *
1190  * Revision 1.51 2008-05-20 10:03:53 joergr
1191  * Added new bilinear and bicubic scaling algorithms for image magnification.
1192  *
1193  * Revision 1.50 2008-05-13 09:54:40 joergr
1194  * Added new parameter to writeImageToDataset() in order to affect the planar
1195  * configuration of the output image/dataset. Changed behaviour: By default,
1196  * the output now uses the same planar configuration as the "original" image
1197  * (previously: always color-by-plane).
1198  *
1199  * Revision 1.49 2007/03/16 11:56:06 joergr
1200  * Introduced new flag that allows to select how to handle the BitsPerTableEntry
1201  * value in the LUT descriptor (use, ignore or check).
1202  *
1203  * Revision 1.48 2006/08/15 16:30:11 meichel
1204  * Updated the code in module dcmimgle to correctly compile when
1205  * all standard C++ classes remain in namespace std.
1206  *
1207  * Revision 1.47 2006/07/10 10:52:27 joergr
1208  * Added support for 32-bit BMP images.
1209  *
1210  * Revision 1.46 2005/12/08 16:47:50 meichel
1211  * Changed include path schema for all DCMTK header files
1212  *
1213  * Revision 1.45 2005/03/09 17:33:16 joergr
1214  * Added mode to writeImageToDataset() which allows the value of BitsStored to
1215  * be determined either from 'used' or from 'possible' pixel values.
1216  *
1217  * Revision 1.44 2004/07/20 18:12:16 joergr
1218  * Added API method to "officially" access the internal intermediate pixel data
1219  * representation (e.g. to get Hounsfield Units for CT images).
1220  *
1221  * Revision 1.43 2004/02/06 11:07:50 joergr
1222  * Distinguish more clearly between const and non-const access to pixel data.
1223  *
1224  * Revision 1.42 2003/12/23 10:51:52 joergr
1225  * Updated documentation to get rid of doxygen warnings.
1226  *
1227  * Revision 1.41 2003/12/17 16:17:29 joergr
1228  * Added new compatibility flag that allows to ignore the third value of LUT
1229  * descriptors and to determine the bits per table entry automatically.
1230  *
1231  * Revision 1.40 2003/12/08 18:30:16 joergr
1232  * Adapted type casts to new-style typecast operators defined in ofcast.h.
1233  * Removed leading underscore characters from preprocessor symbols (reserved
1234  * symbols). Updated CVS header.
1235  *
1236  * Revision 1.39 2003/06/12 15:08:34 joergr
1237  * Fixed inconsistent API documentation reported by Doxygen.
1238  *
1239  * Revision 1.38 2003/05/20 09:20:21 joergr
1240  * Added method returning the number of bytes required to store a single
1241  * rendered frame: getOutputDataSize().
1242  *
1243  * Revision 1.37 2002/12/09 13:32:52 joergr
1244  * Renamed parameter/local variable to avoid name clashes with global
1245  * declaration left and/or right (used for as iostream manipulators).
1246  *
1247  * Revision 1.36 2002/08/02 15:03:53 joergr
1248  * Added function to write the current image (not only a selected frame) to a
1249  * DICOM dataset.
1250  *
1251  * Revision 1.35 2002/06/26 17:20:04 joergr
1252  * Removed superfluous "inline" method specifyer (MSVC6 linker reported an
1253  * error).
1254  *
1255  * Revision 1.34 2002/06/26 16:04:44 joergr
1256  * Added support for polarity flag to color images.
1257  * Added new methods to get the explanation string of stored VOI windows and
1258  * LUTs (not only of the currently selected VOI transformation).
1259  *
1260  * Revision 1.33 2002/01/29 17:05:50 joergr
1261  * Added optional flag to the "Windows DIB" methods allowing to switch off the
1262  * scanline padding.
1263  *
1264  * Revision 1.32 2001/11/19 12:55:54 joergr
1265  * Added parameter 'frame' to setRoiWindow().
1266  *
1267  * Revision 1.31 2001/11/09 16:27:34 joergr
1268  * Added support for Window BMP file format.
1269  * Enhanced and renamed createTrueColorDIB() method.
1270  *
1271  * Revision 1.30 2001/09/28 13:06:10 joergr
1272  * Added routines to get the currently active Polarity and PresentationLUTShape.
1273  * Added method setRoiWindow() which automatically calculates a min-max VOI
1274  * window for a specified rectangular region of the image.
1275  * Added method to extract embedded overlay planes from pixel data and store
1276  * them in group (6xxx,3000) format.
1277  *
1278  * Revision 1.29 2001/06/01 15:49:44 meichel
1279  * Updated copyright header
1280  *
1281  * Revision 1.28 2001/05/14 09:49:17 joergr
1282  * Added support for "1 bit output" of overlay planes; useful to extract
1283  * overlay planes from the pixel data and store them separately in the dataset.
1284  *
1285  * Revision 1.27 2000/07/07 13:42:30 joergr
1286  * Added support for LIN OD presentation LUT shape.
1287  *
1288  * Revision 1.26 2000/06/07 14:30:27 joergr
1289  * Added method to set the image polarity (normal, reverse).
1290  *
1291  * Revision 1.25 2000/03/08 16:24:18 meichel
1292  * Updated copyright header.
1293  *
1294  * Revision 1.24 1999/12/09 17:26:24 joergr
1295  * Split source file dimoimg.cc into 4 parts to avoid compiler problems
1296  * with gcc and additional optimization options.
1297  *
1298  * Revision 1.23 1999/10/20 10:33:15 joergr
1299  * Enhanced method getOverlayData to support 12 bit data for print.
1300  *
1301  * Revision 1.22 1999/10/06 13:38:46 joergr
1302  * Corrected creation of PrintBitmap pixel data: VOI windows should be applied
1303  * before clipping to avoid that the region outside the image (border) is also
1304  * windowed (this requires a new method in dcmimgle to create a DicomImage
1305  * with the grayscale transformations already applied).
1306  *
1307  * Revision 1.21 1999/09/17 12:24:47 joergr
1308  * Added/changed/completed DOC++ style comments in the header files.
1309  *
1310  * Revision 1.20 1999/09/10 08:45:18 joergr
1311  * Added support for CIELAB display function.
1312  *
1313  * Revision 1.19 1999/08/25 16:41:52 joergr
1314  * Added new feature: Allow clipping region to be outside the image
1315  * (overlapping).
1316  *
1317  * Revision 1.18 1999/07/23 14:03:05 joergr
1318  * Added dummy method (no implementation yet) to create inverse LUTs.
1319  * Added method to create 12 bit packed bitmap data (used for grayscale print
1320  * storage).
1321  * Added method to return pointer to currently used display function.
1322  *
1323  * Revision 1.17 1999/04/28 17:03:47 joergr
1324  * Added type casts to NULL pointers returned as 'const char *' to avoid
1325  * compiler warnings reported by gcc 2.7.2.1 (Linux).
1326  *
1327  * Revision 1.16 1999/04/28 14:49:54 joergr
1328  * Added experimental support to create grayscale images with more than 256
1329  * shades of gray to be displayed on a consumer monitor (use pastel colors).
1330  *
1331  * Revision 1.15 1999/03/24 17:20:09 joergr
1332  * Added/Modified comments and formatting.
1333  *
1334  * Revision 1.14 1999/03/22 08:51:39 joergr
1335  * Added parameter to specify (transparent) background color for method
1336  * getOverlayData().
1337  *
1338  * Revision 1.13 1999/02/11 16:34:36 joergr
1339  * Added routine to check whether particular grayscale values are unused in
1340  * the output data.
1341  *
1342  * Revision 1.12 1999/02/08 12:39:05 joergr
1343  * Changed implementation of removeAllOverlays().
1344  *
1345  * Revision 1.11 1999/02/05 16:43:13 joergr
1346  * Added optional parameter to method convertPValueToDDL to specify width
1347  * of output data (number of bits).
1348  *
1349  * Revision 1.10 1999/02/03 17:27:58 joergr
1350  * Added support for calibration according to Barten transformation (incl.
1351  * a DISPLAY file describing the monitor characteristic).
1352  *
1353  * Revision 1.9 1999/01/20 15:03:40 joergr
1354  * Added new output method to fill external memory buffer with rendered pixel
1355  * data.
1356  *
1357  * Revision 1.8 1999/01/11 09:35:10 joergr
1358  * Added parameter to method 'getMinMaxValues()' to return absolute minimum
1359  * and maximum values ('possible') in addition to actually 'used' pixel
1360  * values.
1361  *
1362  * Revision 1.7 1998/12/23 13:21:28 joergr
1363  * Changed parameter type (long to int) to avoid warning reported by MSVC5.
1364  *
1365  * Revision 1.6 1998/12/23 12:38:16 joergr
1366  * Corrected some typos and formatting.
1367  *
1368  * Revision 1.4 1998/12/22 14:26:19 joergr
1369  * Added new parameters to method addOverlay().
1370  *
1371  * Revision 1.3 1998/12/16 16:34:06 joergr
1372  * Added explanation string to LUT class (retrieved from dataset).
1373  * Added explanation string for VOI transformations.
1374  * Renamed 'setNoVoiLutTransformation' method ('Voi' instead of 'VOI').
1375  * Removed several methods used for monochrome images only in base class
1376  * 'DiImage'. Introduced mechanism to use the methods directly.
1377  *
1378  * Revision 1.2 1998/12/14 17:20:03 joergr
1379  * Added methods to add and remove additional overlay planes (still untested).
1380  *
1381  * Revision 1.1 1998/11/27 15:20:57 joergr
1382  * Added copyright message.
1383  * Added methods and constructors for flipping and rotating, changed for
1384  * scaling and clipping.
1385  * Added method to directly create java AWT bitmaps.
1386  * Added constructors to use external modality transformations.
1387  * Added methods to support presentation LUTs and shapes.
1388  *
1389  * Revision 1.6 1998/07/01 08:39:22 joergr
1390  * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional
1391  * options), e.g. add copy constructors.
1392  *
1393  * Revision 1.5 1998/05/11 14:53:20 joergr
1394  * Added CVS/RCS header to each file.
1395  *
1396  *
1397  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2