OFFIS DCMTK  Version 3.6.0
dcmimage.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: Provides main interface to the "DICOM image toolkit"
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:16:25 $
22  * CVS/RCS Revision: $Revision: 1.65 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DCMIMAGE_H
31 #define DCMIMAGE_H
32 
33 #include "dcmtk/config/osconfig.h"
34 
35 #include "dcmtk/ofstd/ofcast.h"
36 
37 #include "dcmtk/dcmimgle/dimoimg.h"
38 #include "dcmtk/dcmimgle/didispfn.h"
39 #include "dcmtk/dcmimgle/diutils.h"
40 
41 
42 /*------------------------*
43  * forward declarations *
44  *------------------------*/
45 
46 class DcmXfer;
47 class DcmObject;
48 class DcmOverlayData;
49 class DcmLongString;
50 class DcmUnsignedShort;
51 
52 class DiPixel;
53 class DiDocument;
54 class DiPluginFormat;
55 
56 
57 /*---------------------*
58  * class declaration *
59  *---------------------*/
60 
65 {
66 
67  public:
68 
69  // --- constructors and destructor
70 
81  DicomImage(const char *filename,
82  const unsigned long flags = 0,
83  const unsigned long fstart = 0,
84  const unsigned long fcount = 0);
85 
86 #ifndef STARVIEW
87 
99  DicomImage(DcmObject *object,
100  const E_TransferSyntax xfer,
101  const unsigned long flags = 0,
102  const unsigned long fstart = 0,
103  const unsigned long fcount = 0);
104 
121  DicomImage(DcmObject *object,
122  const E_TransferSyntax xfer,
123  const double slope,
124  const double intercept,
125  const unsigned long flags = 0,
126  const unsigned long fstart = 0,
127  const unsigned long fcount = 0);
128 
146  DicomImage(DcmObject *object,
147  E_TransferSyntax xfer,
148  const DcmUnsignedShort &data,
149  const DcmUnsignedShort &descriptor,
150  const DcmLongString *explanation = NULL,
151  const unsigned long flags = 0,
152  const unsigned long fstart = 0,
153  const unsigned long fcount = 0);
154 #endif
155 
158  virtual ~DicomImage();
159 
160 
161  // --- multi-frame handling
162 
177  inline int processNextFrames(const unsigned long fcount = 0)
178  {
179  return (Image != NULL) ?
180  Image->processNextFrames(fcount) : 0;
181  }
182 
183 
184  // --- information: return requested value if successful
185 
192  static const char *getString(const EI_Status status);
193 
200  static const char *getString(const EP_Interpretation interpret);
201 
206  inline EI_Status getStatus() const
207  {
208  return (Image != NULL) ?
210  }
211 
219  inline unsigned long getFrameCount() const
220  {
221  return (Image != NULL) ?
222  Image->getNumberOfFrames() : 0;
223  }
224 
231  inline unsigned long getFirstFrame() const
232  {
233  return (Image != NULL) ?
234  Image->getFirstFrame() : 0;
235  }
236 
242  inline unsigned long getRepresentativeFrame() const
243  {
244  return (Image != NULL) ?
246  }
247 
252  inline unsigned long getWidth() const
253  {
254  return (Image != NULL) ?
255  Image->getColumns() : 0;
256  }
257 
262  inline unsigned long getHeight() const
263  {
264  return (Image != NULL) ?
265  Image->getRows() : 0;
266  }
267 
272  inline int getDepth() const
273  {
274  return (Image != NULL) ?
275  Image->getBits() : 0;
276  }
277 
291  inline int getMinMaxValues(double &min,
292  double &max,
293  const int mode = 0) const
294  {
295  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
296  Image->getMonoImagePtr()->getMinMaxValues(min, max, mode) : 0;
297  }
298 
305  inline double getWidthHeightRatio() const
306  {
307  return (Image != NULL) ?
308  Image->getColumnRowRatio() : 0;
309  }
310 
318  inline double getHeightWidthRatio() const
319  {
320  return (Image != NULL) ?
321  Image->getRowColumnRatio() : 0;
322  }
323 
330  inline int setWidthHeightRatio(const double ratio) const
331  {
332  return (Image != NULL) ?
333  Image->setColumnRowRatio(ratio) : 0;
334  }
335 
342  inline int setHeightWidthRatio(const double ratio) const
343  {
344  return (Image != NULL) ?
345  Image->setRowColumnRatio(ratio) : 0;
346  }
347 
354  inline int isOutputValueUnused(const unsigned long value)
355  {
356  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
357  Image->getMonoImagePtr()->isValueUnused(value) : 0;
358  }
359 
360  // --- output: return pointer to output data if successful
361 
373  inline unsigned long getOutputDataSize(const int bits = 0) const
374  {
375  return (Image != NULL) ?
376  Image->getOutputDataSize(Image->getBits(bits)) : 0;
377  }
378 
397  inline const void *getOutputData(const int bits = 0,
398  const unsigned long frame = 0,
399  const int planar = 0)
400  {
401  return (Image != NULL) ?
402  Image->getOutputData(frame, Image->getBits(bits), planar) : NULL;
403  }
404 
423  inline int getOutputData(void *buffer,
424  const unsigned long size,
425  const int bits = 0,
426  const unsigned long frame = 0,
427  const int planar = 0)
428  {
429  return (Image != NULL) ?
430  Image->getOutputData(buffer, size, frame, Image->getBits(bits), planar) : 0;
431  }
432 
444  inline const void *getOutputPlane(const int plane) const
445  {
446  return (Image != NULL) ?
447  Image->getOutputPlane(plane) : NULL;
448  }
449 
453  inline void deleteOutputData() const
454  {
455  if (Image != NULL)
457  }
458 
459  // --- misc
460 
465  inline int isMonochrome() const
466  {
467  return (PhotometricInterpretation == EPI_Monochrome1) || (PhotometricInterpretation == EPI_Monochrome2);
468  }
469 
474  inline EP_Interpretation getPhotometricInterpretation() const
475  {
477  }
478 
483  int hasSOPclassUID(const char *uid) const;
484 
496  inline const DiPixel *getInterData() const
497  {
498  return (Image != NULL) ?
499  Image->getInterData() : NULL;
500  }
501 
502  // --- display function for output device characteristic (calibration):
503  // only applicable to grayscale images
504 
510  {
511  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
512  Image->getMonoImagePtr()->getDisplayFunction() : OFstatic_cast(DiDisplayFunction *, NULL);
513  }
514 
522  {
523  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
524  Image->getMonoImagePtr()->setDisplayFunction(display) : 0;
525  }
526 
534  inline int setNoDisplayFunction()
535  {
536  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
538  }
539 
546  inline int deleteDisplayLUT(const int bits = 0)
547  {
548  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
549  Image->getMonoImagePtr()->deleteDisplayLUT(bits) : 0;
550  }
551 
563  inline int convertPValueToDDL(const Uint16 pvalue,
564  Uint16 &ddl,
565  const int bits = 8)
566  {
567  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
568  Image->getMonoImagePtr()->convertPValueToDDL(pvalue, ddl, bits) : 0;
569  }
570 
571  // --- windowing (voi): only applicable to grayscale images
572  // return true if successful (see also 'dimoimg.cc')
573 
582  {
583  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
585  }
586 
598  inline int setMinMaxWindow(const int idx = 0)
599  {
600  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
602  }
603 
612  inline int setHistogramWindow(const double thresh = 0.05)
613  {
614  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
615  Image->getMonoImagePtr()->setHistogramWindow(thresh) : 0;
616  }
617 
634  inline int setRoiWindow(const unsigned long left_pos,
635  const unsigned long top_pos,
636  const unsigned long width,
637  const unsigned long height,
638  const unsigned long frame = 0)
639  {
640  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
641  Image->getMonoImagePtr()->setRoiWindow(left_pos, top_pos, width, height, frame) : 0;
642  }
643 
652  inline int setWindow(const unsigned long window)
653  {
654  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
655  Image->getMonoImagePtr()->setWindow(window) : 0;
656  }
657 
668  inline int setWindow(const double center,
669  const double width)
670  {
671  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
672  Image->getMonoImagePtr()->setWindow(center, width) : 0;
673  }
674 
682  inline int getWindow(double &center,
683  double &width)
684  {
685  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
686  Image->getMonoImagePtr()->getWindow(center, width) : 0;
687  }
688 
694  inline unsigned long getWindowCount() const
695  {
696  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
698  }
699 
710  inline int setVoiLutFunction(const EF_VoiLutFunction function)
711  {
712  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
713  Image->getMonoImagePtr()->setVoiLutFunction(function) : 0;
714  }
715 
722  inline EF_VoiLutFunction getVoiLutFunction() const
723  {
724  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
725  Image->getMonoImagePtr()->getVoiLutFunction() : EFV_Default;
726  }
727 
740  inline int setVoiLut(const DcmUnsignedShort &data,
741  const DcmUnsignedShort &descriptor,
742  const DcmLongString *explanation = NULL,
743  const EL_BitsPerTableEntry descripMode = ELM_UseValue)
744  {
745  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
746  Image->getMonoImagePtr()->setVoiLut(data, descriptor, explanation, descripMode) : 0;
747  }
748 
758  inline int setVoiLut(const unsigned long table,
759  const EL_BitsPerTableEntry descripMode = ELM_UseValue)
760  {
761  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
762  Image->getMonoImagePtr()->setVoiLut(table, descripMode) : 0;
763  }
764 
769  inline unsigned long getVoiLutCount() const
770  {
771  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
773  }
774 
779  inline const char *getVoiTransformationExplanation() const
780  {
781  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
782  Image->getMonoImagePtr()->getVoiTransformationExplanation() : OFstatic_cast(const char *, NULL);
783  }
784 
792  inline const char *getVoiWindowExplanation(const unsigned long window,
793  OFString &explanation) const
794  {
795  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
796  Image->getMonoImagePtr()->getVoiWindowExplanation(window, explanation) : OFstatic_cast(const char *, NULL);
797  }
798 
806  inline const char *getVoiLutExplanation(const unsigned long table,
807  OFString &explanation) const
808  {
809  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
810  Image->getMonoImagePtr()->getVoiLutExplanation(table, explanation) : OFstatic_cast(const char *, NULL);
811  }
812 
817  inline const char *getModalityLutExplanation() const
818  {
819  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
820  Image->getMonoImagePtr()->getModalityLutExplanation() : OFstatic_cast(const char *, NULL);
821  }
822 
823  // --- hardcopy parameters
824 
830  inline EP_Polarity getPolarity() const
831  {
832  return (Image != NULL) ?
833  Image->getPolarity() : EPP_Normal;
834  }
835 
844  inline int setPolarity(const EP_Polarity polarity)
845  {
846  return (Image != NULL) ?
847  Image->setPolarity(polarity) : 0;
848  }
849 
863  inline int setHardcopyParameters(const unsigned int min,
864  const unsigned int max,
865  const unsigned int reflect,
866  const unsigned int illumin)
867  {
868  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
869  Image->getMonoImagePtr()->setHardcopyParameters(min, max, reflect, illumin) : 0;
870  }
871 
872  // --- presentation LUT: only applicable to grayscale images
873 
880  inline ES_PresentationLut getPresentationLutShape() const
881  {
882  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
883  Image->getMonoImagePtr()->getPresentationLutShape() : ESP_Default;
884  }
885 
897  inline int setPresentationLutShape(const ES_PresentationLut shape)
898  {
899  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
901  }
902 
915  inline int setPresentationLut(const DcmUnsignedShort &data,
916  const DcmUnsignedShort &descriptor,
917  const DcmLongString *explanation = NULL,
918  const EL_BitsPerTableEntry descripMode = ELM_UseValue)
919  {
920  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
921  Image->getMonoImagePtr()->setPresentationLut(data, descriptor, explanation, descripMode) : 0;
922  }
923 
928  inline const char *getPresentationLutExplanation() const
929  {
930  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
931  Image->getMonoImagePtr()->getPresentationLutExplanation() : OFstatic_cast(const char *, NULL);
932  }
933 
945  const DcmUnsignedShort &descriptor,
946  const EL_BitsPerTableEntry descripMode = ELM_UseValue)
947  {
948  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
949  Image->getMonoImagePtr()->setInversePresentationLut(data, descriptor, descripMode) : 0;
950  }
951 
952  // --- overlays: return true (!0) if successful (see also 'diovlay.cc')
953  // only applicable to grayscale images
954 
971  inline int addOverlay(const unsigned int group,
972  const signed int left_pos,
973  const signed int top_pos,
974  const unsigned int width,
975  const unsigned int height,
976  const DcmOverlayData &data,
977  const DcmLongString &label,
978  const DcmLongString &description,
979  const EM_Overlay mode = EMO_Default)
980  {
981  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
982  Image->getMonoImagePtr()->addOverlay(group, left_pos, top_pos, width, height, data, label, description, mode) : 0;
983  }
984 
991  inline int removeOverlay(const unsigned int group)
992  {
993  return ((Image != NULL) && (Image->getOverlayPtr(1) != NULL)) ?
994  Image->getOverlayPtr(1)->removePlane(group) : 0;
995  }
996 
1002  inline int removeAllOverlays()
1003  {
1004  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
1006  }
1007 
1016  inline int isOverlayVisible(const unsigned int plane,
1017  const unsigned int idx = 0)
1018  {
1019  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1020  Image->getOverlayPtr(idx)->isPlaneVisible(plane) : 0;
1021  }
1022 
1031  inline int showOverlay(const unsigned int plane,
1032  const unsigned int idx = 0)
1033  {
1034  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1035  Image->getOverlayPtr(idx)->showPlane(plane) : 0;
1036  }
1037 
1048  inline int showOverlay(const unsigned int plane,
1049  const EM_Overlay mode,
1050  const double fore = 1.0,
1051  const double thresh = 0.5,
1052  const unsigned int idx = 0)
1053  {
1054  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1055  Image->getOverlayPtr(idx)->showPlane(plane, fore, thresh, mode) : 0;
1056  }
1057 
1065  inline int showOverlay(const unsigned int plane,
1066  const Uint16 pvalue)
1067  {
1068  return ((Image != NULL) && (Image->getOverlayPtr(1) != NULL)) ?
1069  Image->getOverlayPtr(1)->showPlane(plane, pvalue) : 0;
1070  }
1071 
1079  inline int showAllOverlays(const unsigned int idx = 0)
1080  {
1081  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1082  Image->getOverlayPtr(idx)->showAllPlanes() : 0;
1083  }
1084 
1095  inline int showAllOverlays(const EM_Overlay mode,
1096  const double fore = 1,
1097  const double thresh = 0.5,
1098  const unsigned int idx = 0)
1099  {
1100  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1101  Image->getOverlayPtr(idx)->showAllPlanes(fore, thresh, mode) : 0;
1102  }
1103 
1112  inline int hideOverlay(const unsigned int plane,
1113  const unsigned int idx = 0)
1114  {
1115  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1116  Image->getOverlayPtr(idx)->hidePlane(plane) : 0;
1117  }
1118 
1126  inline int hideAllOverlays(const unsigned int idx = 0)
1127  {
1128  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1129  Image->getOverlayPtr(idx)->hideAllPlanes() : 0;
1130  }
1131 
1142  inline int placeOverlay(const unsigned int plane,
1143  const signed int left_pos,
1144  const signed int top_pos,
1145  const unsigned int idx = 0)
1146  {
1147  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1148  Image->getOverlayPtr(idx)->placePlane(plane, left_pos, top_pos) : 0;
1149  }
1150 
1157  inline unsigned int getOverlayCount(const unsigned int idx = 0) const
1158  {
1159  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1160  Image->getOverlayPtr(idx)->getCount() : 0;
1161  }
1162 
1170  inline unsigned int getOverlayGroupNumber(const unsigned int plane,
1171  const unsigned int idx = 0) const
1172  {
1173  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1174  Image->getOverlayPtr(idx)->getPlaneGroupNumber(plane) : 0;
1175  }
1176 
1184  inline const char *getOverlayLabel(const unsigned int plane,
1185  const unsigned int idx = 0) const
1186  {
1187  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1188  Image->getOverlayPtr(idx)->getPlaneLabel(plane) : OFstatic_cast(const char *, NULL);
1189  }
1190 
1198  inline const char *getOverlayDescription(const unsigned int plane,
1199  const unsigned int idx = 0) const
1200  {
1201  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1202  Image->getOverlayPtr(idx)->getPlaneDescription(plane) : OFstatic_cast(const char *, NULL);
1203  }
1204 
1212  inline EM_Overlay getOverlayMode(const unsigned int plane,
1213  const unsigned int idx = 0) const
1214  {
1215  return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ?
1216  Image->getOverlayPtr(idx)->getPlaneMode(plane) : EMO_Default;
1217  }
1218 
1246  const void *getOverlayData(const unsigned int plane,
1247  unsigned int &left_pos,
1248  unsigned int &top_pos,
1249  unsigned int &width,
1250  unsigned int &height,
1251  EM_Overlay &mode,
1252  const unsigned long frame = 0,
1253  const int bits = 8,
1254  const Uint16 fore = 0xff,
1255  const Uint16 back = 0x0,
1256  const unsigned int idx = 2) const
1257  {
1258  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
1259  Image->getMonoImagePtr()->getOverlayData(frame, plane, left_pos, top_pos, width, height, mode, idx, bits, fore, back) : NULL;
1260  }
1261 
1282  const void *getFullOverlayData(const unsigned int plane,
1283  unsigned int &width,
1284  unsigned int &height,
1285  const unsigned long frame = 0,
1286  const int bits = 8,
1287  const Uint16 fore = 0xff,
1288  const Uint16 back = 0x0,
1289  const unsigned int idx = 0) const
1290  {
1291  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
1292  Image->getMonoImagePtr()->getFullOverlayData(frame, plane, width, height, idx, bits, fore, back) : NULL;
1293  }
1294 
1298  inline void deleteOverlayData() const
1299  {
1300  if ((Image != NULL) && (Image->getMonoImagePtr() != NULL))
1302  }
1303 
1320  unsigned long create6xxx3000OverlayData(Uint8 *&buffer,
1321  const unsigned int plane,
1322  unsigned int &width,
1323  unsigned int &height,
1324  unsigned long &frames,
1325  const unsigned int idx = 0) const
1326  {
1327  return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ?
1328  Image->getMonoImagePtr()->create6xxx3000OverlayData(buffer, plane, width, height, frames, idx) : 0;
1329  }
1330 
1331 
1332  // --- create...Image: return pointer to new 'DicomImage' object, memory isn't handled internally !
1333 
1342  DicomImage *createDicomImage(unsigned long fstart = 0,
1343  unsigned long fcount = 0) const;
1344 
1360  DicomImage *createScaledImage(const unsigned long width,
1361  const unsigned long height = 0,
1362  const int interpolate = 0,
1363  int aspect = 0) const;
1364 
1380  DicomImage *createScaledImage(const double xfactor,
1381  const double yfactor = 0,
1382  const int interpolate = 0,
1383  const int aspect = 0) const;
1384 
1407  DicomImage *createScaledImage(const signed long left_pos,
1408  const signed long top_pos,
1409  unsigned long clip_width,
1410  unsigned long clip_height,
1411  unsigned long scale_width = 0,
1412  unsigned long scale_height = 0,
1413  const int interpolate = 0,
1414  int aspect = 0,
1415  const Uint16 pvalue = 0) const;
1416 
1439  DicomImage *createScaledImage(const signed long left_pos,
1440  const signed long top_pos,
1441  unsigned long width,
1442  unsigned long height,
1443  const double xfactor,
1444  const double yfactor = 0,
1445  const int interpolate = 0,
1446  const int aspect = 0,
1447  const Uint16 pvalue = 0) const;
1448 
1461  DicomImage *createClippedImage(const signed long left_pos,
1462  const signed long top_pos,
1463  unsigned long width = 0,
1464  unsigned long height = 0,
1465  const Uint16 pvalue = 0) const;
1466 
1476  int flipImage(int horz = 1,
1477  int vert = 0) const;
1478 
1487  DicomImage *createFlippedImage(int horz = 1,
1488  int vert = 0) const;
1489 
1498  int rotateImage(signed int degree) const;
1499 
1507  DicomImage *createRotatedImage(signed int degree) const;
1508 
1520  DicomImage *createMonochromeImage(const double red = 0.299,
1521  const double green = 0.587,
1522  const double blue = 0.114) const;
1523 
1548  unsigned long createWindowsDIB(void *&data,
1549  const unsigned long size,
1550  const unsigned long frame = 0,
1551  const int bits = 24,
1552  const int upsideDown = 0,
1553  const int padding = 1)
1554  {
1555  return (Image != NULL) ?
1556  Image->createDIB(data, size, frame, bits, upsideDown, padding) : 0;
1557  }
1558 
1571  unsigned long createJavaAWTBitmap(void *&data,
1572  const unsigned long frame = 0,
1573  const int bits = 32)
1574  {
1575  return (Image != NULL) ?
1576  Image->createAWTBitmap(data, frame, bits) : 0;
1577  }
1578 
1588  static void *create12BitPackedBitmap(const void *buffer,
1589  const unsigned long size,
1590  const unsigned long count)
1591  {
1592  return DiMonoImage::createPackedBitmap(buffer, size, count, 16, 12);
1593  }
1594 
1604  DicomImage *createMonoOutputImage(const unsigned long frame,
1605  const int bits);
1606 
1607  // --- output image file: return true ('1') if successful
1608 
1636  inline int writeFrameToDataset(DcmItem &dataset,
1637  const int bits = 0,
1638  const unsigned long frame = 0,
1639  const int planar = 0)
1640  {
1641  return (Image != NULL) ?
1642  Image->writeFrameToDataset(dataset, frame, bits, planar) : 0;
1643  }
1644 
1673  inline int writeImageToDataset(DcmItem &dataset,
1674  const int mode = 0,
1675  const int planar = 2)
1676  {
1677  return (Image != NULL) ?
1678  Image->writeImageToDataset(dataset, mode, planar) : 0;
1679  }
1680 
1694  int writePPM(const char *filename,
1695  const int bits = 0,
1696  const unsigned long frame = 0);
1697 
1711  int writePPM(STD_NAMESPACE ostream& stream,
1712  const int bits = 0,
1713  const unsigned long frame = 0);
1714 
1728  int writePPM(FILE *stream,
1729  const int bits = 0,
1730  const unsigned long frame = 0);
1731 
1745  int writeRawPPM(const char *filename,
1746  const int bits = 0,
1747  const unsigned long frame= 0);
1748 
1762  int writeRawPPM(FILE *stream,
1763  const int bits = 0,
1764  const unsigned long frame = 0);
1765 
1778  int writeBMP(FILE *stream,
1779  const int bits = 0,
1780  const unsigned long frame = 0);
1781 
1794  int writeBMP(const char *filename,
1795  const int bits = 0,
1796  const unsigned long frame = 0);
1797 
1807  int writePluginFormat(const DiPluginFormat *plugin,
1808  FILE *stream,
1809  const unsigned long frame = 0);
1810 
1820  int writePluginFormat(const DiPluginFormat *plugin,
1821  const char *filename,
1822  const unsigned long frame = 0);
1823 
1824 
1825  protected:
1826 
1833  DicomImage(const DicomImage *dicom,
1834  DiImage *image,
1835  const EP_Interpretation interpret = EPI_Unknown);
1836 
1840  void Init();
1841 
1846  int checkDataDictionary();
1847 
1852  const char *getSOPclassUID() const;
1853 
1862  int normalizeDegreeValue(signed int &degree) const;
1863 
1864 
1865  private:
1866 
1868  EI_Status ImageStatus;
1870  EP_Interpretation PhotometricInterpretation;
1871 
1876 
1877  // --- declarations to avoid compiler warnings
1878 
1879  DicomImage(const DicomImage &);
1880  DicomImage &operator=(const DicomImage &);
1881 };
1882 
1883 
1884 #endif
1885 
1886 
1887 /*
1888  *
1889  * CVS/RCS Log:
1890  * $Log: dcmimage.h,v $
1891  * Revision 1.65 2010-10-14 13:16:25 joergr
1892  * Updated copyright header. Added reference to COPYRIGHT file.
1893  *
1894  * Revision 1.64 2010-10-05 15:24:02 joergr
1895  * Added preliminary support for VOI LUT function. Please note, however, that
1896  * the sigmoid transformation is not yet implemented.
1897  *
1898  * Revision 1.63 2010-03-02 09:23:32 joergr
1899  * Enhanced comments of some methods, e.g. processNextFrames().
1900  *
1901  * Revision 1.62 2009-11-25 15:07:00 joergr
1902  * Added new method which allows for processing the frames of a multi-frame
1903  * image successively. The getString() method now returns the Defined Term of
1904  * the attribute PhotometricInterpretation.
1905  *
1906  * Revision 1.61 2009-02-12 12:03:56 joergr
1907  * Never update value of ImagerPixelSpacing when image is scaled, use
1908  * PixelSpacing instead.
1909  * Added support for NominalScannedPixelSpacing in order to determine the pixel
1910  * aspect ratio (used for the new SC image IODs).
1911  *
1912  * Revision 1.60 2008-07-11 08:35:28 joergr
1913  * Fixed typo in API documentation.
1914  *
1915  * Revision 1.59 2008-05-20 10:02:33 joergr
1916  * Added new bilinear and bicubic scaling algorithms for image magnification.
1917  *
1918  * Revision 1.58 2008-05-13 09:54:40 joergr
1919  * Added new parameter to writeImageToDataset() in order to affect the planar
1920  * configuration of the output image/dataset. Changed behaviour: By default,
1921  * the output now uses the same planar configuration as the "original" image
1922  * (previously: always color-by-plane).
1923  *
1924  * Revision 1.57 2007/03/16 11:56:05 joergr
1925  * Introduced new flag that allows to select how to handle the BitsPerTableEntry
1926  * value in the LUT descriptor (use, ignore or check).
1927  *
1928  * Revision 1.56 2006/08/15 16:30:11 meichel
1929  * Updated the code in module dcmimgle to correctly compile when
1930  * all standard C++ classes remain in namespace std.
1931  *
1932  * Revision 1.55 2006/07/10 10:52:27 joergr
1933  * Added support for 32-bit BMP images.
1934  *
1935  * Revision 1.54 2005/12/08 16:47:31 meichel
1936  * Changed include path schema for all DCMTK header files
1937  *
1938  * Revision 1.53 2005/03/09 17:33:40 joergr
1939  * Added mode to writeImageToDataset() which allows the value of BitsStored to
1940  * be determined either from 'used' or from 'possible' pixel values.
1941  *
1942  * Revision 1.52 2004/07/20 18:12:16 joergr
1943  * Added API method to "officially" access the internal intermediate pixel data
1944  * representation (e.g. to get Hounsfield Units for CT images).
1945  *
1946  * Revision 1.51 2003/12/17 16:17:29 joergr
1947  * Added new compatibility flag that allows to ignore the third value of LUT
1948  * descriptors and to determine the bits per table entry automatically.
1949  *
1950  * Revision 1.50 2003/12/11 17:22:19 joergr
1951  * Added comment to getOutputData/Plane() methods that the rendered pixel data
1952  * is always unsigned.
1953  *
1954  * Revision 1.49 2003/12/08 18:39:00 joergr
1955  * Adapted type casts to new-style typecast operators defined in ofcast.h.
1956  * Removed leading underscore characters from preprocessor symbols (reserved
1957  * symbols). Updated CVS header.
1958  *
1959  * Revision 1.48 2003/06/12 15:08:34 joergr
1960  * Fixed inconsistent API documentation reported by Doxygen.
1961  *
1962  * Revision 1.47 2003/05/20 09:24:31 joergr
1963  * Added method returning the number of bytes required to store a single
1964  * rendered frame: getOutputDataSize().
1965  *
1966  * Revision 1.46 2002/12/09 13:32:50 joergr
1967  * Renamed parameter/local variable to avoid name clashes with global
1968  * declaration left and/or right (used for as iostream manipulators).
1969  *
1970  * Revision 1.45 2002/10/21 10:09:58 joergr
1971  * Slightly enhanced comments for getOutputData().
1972  *
1973  * Revision 1.44 2002/08/21 09:51:43 meichel
1974  * Removed DicomImage and DiDocument constructors that take a DcmStream
1975  * parameter
1976  *
1977  * Revision 1.43 2002/08/02 15:02:34 joergr
1978  * Enhanced writeFrameToDataset() routine (remove out-data DICOM attributes
1979  * from the dataset).
1980  * Added function to write the current image (not only a selected frame) to a
1981  * DICOM dataset.
1982  *
1983  * Revision 1.42 2002/07/19 08:24:20 joergr
1984  * Enhanced/corrected comments.
1985  *
1986  * Revision 1.41 2002/07/05 10:37:47 joergr
1987  * Added comments.
1988  *
1989  * Revision 1.40 2002/06/26 16:00:25 joergr
1990  * Added support for polarity flag to color images.
1991  * Added new method to write a selected frame to a DICOM dataset (incl. required
1992  * attributes from the "Image Pixel Module").
1993  * Added new methods to get the explanation string of stored VOI windows and
1994  * LUTs (not only of the currently selected VOI transformation).
1995  *
1996  * Revision 1.39 2002/01/29 17:05:49 joergr
1997  * Added optional flag to the "Windows DIB" methods allowing to switch off the
1998  * scanline padding.
1999  *
2000  * Revision 1.38 2001/11/27 18:18:20 joergr
2001  * Added support for plugable output formats in class DicomImage. First
2002  * implementation is JPEG.
2003  *
2004  * Revision 1.37 2001/11/19 12:54:29 joergr
2005  * Added parameter 'frame' to setRoiWindow().
2006  *
2007  * Revision 1.36 2001/11/09 16:25:13 joergr
2008  * Added support for Window BMP file format.
2009  * Enhanced and renamed createTrueColorDIB() method.
2010  *
2011  * Revision 1.35 2001/09/28 13:00:55 joergr
2012  * Changed default behaviour of setMinMaxWindow().
2013  * Added routines to get the currently active Polarity and PresentationLUTShape.
2014  * Added method setRoiWindow() which automatically calculates a min-max VOI
2015  * window for a specified rectangular region of the image.
2016  * Added method to extract embedded overlay planes from pixel data and store
2017  * them in group (6xxx,3000) format.
2018  * Added new flag (CIF_KeepYCbCrColorModel) which avoids conversion of YCbCr
2019  * color models to RGB.
2020  *
2021  * Revision 1.34 2001/06/20 15:12:49 joergr
2022  * Enhanced multi-frame support for command line tool 'dcm2pnm': extract all
2023  * or a range of frames with one call.
2024  *
2025  * Revision 1.33 2001/05/14 09:49:17 joergr
2026  * Added support for "1 bit output" of overlay planes; useful to extract
2027  * overlay planes from the pixel data and store them separately in the dataset.
2028  *
2029  * Revision 1.32 2001/05/10 16:46:26 joergr
2030  * Enhanced comments of some overlay related methods.
2031  *
2032  * Revision 1.31 2000/07/07 13:42:11 joergr
2033  * Added support for LIN OD presentation LUT shape.
2034  *
2035  * Revision 1.30 2000/06/07 14:30:26 joergr
2036  * Added method to set the image polarity (normal, reverse).
2037  *
2038  * Revision 1.29 2000/04/27 13:08:37 joergr
2039  * Dcmimgle library code now consistently uses ofConsole for error output.
2040  *
2041  * Revision 1.28 2000/03/08 16:24:13 meichel
2042  * Updated copyright header.
2043  *
2044  * Revision 1.27 2000/03/06 18:16:02 joergr
2045  * Removed inline specifier from a 'large' method (reported by Sun CC 4.2).
2046  *
2047  * Revision 1.26 1999/11/19 12:36:55 joergr
2048  * Added explicit type cast to avoid compiler warnings (reported by gcc
2049  * 2.7.2.1 on Linux).
2050  *
2051  * Revision 1.25 1999/10/20 10:32:05 joergr
2052  * Enhanced method getOverlayData to support 12 bit data for print.
2053  *
2054  * Revision 1.24 1999/10/06 13:26:08 joergr
2055  * Corrected creation of PrintBitmap pixel data: VOI windows should be applied
2056  * before clipping to avoid that the region outside the image (border) is also
2057  * windowed (this requires a new method in dcmimgle to create a DicomImage
2058  * with the grayscale transformations already applied).
2059  *
2060  * Revision 1.23 1999/09/17 12:06:17 joergr
2061  * Added/changed/completed DOC++ style comments in the header files.
2062  *
2063  * Revision 1.22 1999/09/10 08:45:17 joergr
2064  * Added support for CIELAB display function.
2065  *
2066  * Revision 1.21 1999/09/08 15:19:23 joergr
2067  * Completed implementation of setting inverse presentation LUT as needed
2068  * e.g. for DICOM print (invert 8->12 bits PLUT).
2069  *
2070  * Revision 1.20 1999/08/25 16:38:48 joergr
2071  * Allow clipping region to be outside the image (overlapping).
2072  *
2073  * Revision 1.19 1999/07/23 13:50:07 joergr
2074  * Added methods to set 'PixelAspectRatio'.
2075  * Added dummy method (no implementation yet) to create inverse LUTs.
2076  * Added method to create 12 bit packed bitmap data (used for grayscale print
2077  * storage).
2078  * Added method to return pointer to currently used display function.
2079  * Added new interpolation algorithm for scaling.
2080  *
2081  * Revision 1.18 1999/05/10 09:33:54 joergr
2082  * Moved dcm2pnm version definition from module dcmimgle to dcmimage.
2083  *
2084  * Revision 1.17 1999/05/03 11:09:27 joergr
2085  * Minor code purifications to keep Sun CC 2.0.1 quiet.
2086  *
2087  * Revision 1.16 1999/04/28 14:45:54 joergr
2088  * Added experimental support to create grayscale images with more than 256
2089  * shades of gray to be displayed on a consumer monitor (use pastel colors).
2090  *
2091  * Revision 1.15 1999/03/24 17:19:56 joergr
2092  * Added/Modified comments and formatting.
2093  *
2094  * Revision 1.14 1999/03/22 08:51:06 joergr
2095  * Added parameter to specify (transparent) background color for method
2096  * getOverlayData().
2097  * Added/Changed comments.
2098  *
2099  * Revision 1.13 1999/03/03 11:43:39 joergr
2100  * Changed comments.
2101  *
2102  * Revision 1.12 1999/02/11 15:35:04 joergr
2103  * Added routine to check whether particular grayscale values are unused in
2104  * the output data.
2105  *
2106  * Revision 1.11 1999/02/09 14:21:08 meichel
2107  * Corrected const signatures of some ctor declarations
2108  *
2109  * Revision 1.10 1999/02/08 12:37:35 joergr
2110  * Changed implementation of removeAllOverlays().
2111  * Added parameter 'idx' to some overlay methods to distinguish between
2112  * built-in and additional overlay planes.
2113  *
2114  * Revision 1.9 1999/02/05 16:42:22 joergr
2115  * Added optional parameter to method convertPValueToDDL to specify width
2116  * of output data (number of bits).
2117  *
2118  * Revision 1.8 1999/02/03 16:59:54 joergr
2119  * Added support for calibration according to Barten transformation (incl.
2120  * a DISPLAY file describing the monitor characteristic).
2121  *
2122  * Revision 1.7 1999/01/20 14:58:26 joergr
2123  * Added new output method to fill external memory buffer with rendered pixel
2124  * data.
2125  *
2126  * Revision 1.6 1999/01/11 09:31:20 joergr
2127  * Added parameter to method 'getMinMaxValues()' to return absolute minimum
2128  * and maximum values ('possible') in addition to actually 'used' pixel
2129  * values.
2130  *
2131  * Revision 1.5 1998/12/23 11:31:58 joergr
2132  * Changed order of parameters for addOverlay() and getOverlayData().
2133  *
2134  * Revision 1.3 1998/12/16 16:26:17 joergr
2135  * Added explanation string to LUT class (retrieved from dataset).
2136  * Added explanation string for VOI transformations.
2137  * Added method to export overlay planes (create 8-bit bitmap).
2138  * Renamed 'setNoVoiLutTransformation' method ('Voi' instead of 'VOI').
2139  * Removed several methods used for monochrome images only in base class
2140  * 'DiImage'. Introduced mechanism to use the methods directly.
2141  *
2142  * Revision 1.2 1998/12/14 17:14:07 joergr
2143  * Added methods to add and remove additional overlay planes (still untested).
2144  * Added methods to support overlay labels and descriptions.
2145  *
2146  * Revision 1.1 1998/11/27 14:50:00 joergr
2147  * Added copyright message.
2148  * Added methods to convert module defined enum types to strings.
2149  * Added methods to support presentation LUTs and shapes.
2150  * Moved type definitions to diutils.h.
2151  * Added constructors to use external modality transformations.
2152  * Added method to directly create java AWT bitmaps.
2153  * Added methods and constructors for flipping and rotating, changed for
2154  * scaling and clipping.
2155  *
2156  * Revision 1.12 1998/07/01 08:39:17 joergr
2157  * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional
2158  * options), e.g. add copy constructors.
2159  *
2160  * Revision 1.11 1998/06/25 08:50:09 joergr
2161  * Added compatibility mode to support ACR-NEMA images and wrong
2162  * palette attribute tags.
2163  *
2164  * Revision 1.10 1998/05/11 14:53:07 joergr
2165  * Added CVS/RCS header to each file.
2166  *
2167  *
2168  */


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