00001 /* 00002 * 00003 * Copyright (C) 1996-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmimgle 00015 * 00016 * Author: Joerg Riesmeier 00017 * 00018 * Purpose: Provides main interface to the "DICOM image toolkit" 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:16:25 $ 00022 * CVS/RCS Revision: $Revision: 1.65 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 00030 #ifndef DCMIMAGE_H 00031 #define DCMIMAGE_H 00032 00033 #include "dcmtk/config/osconfig.h" 00034 00035 #include "dcmtk/ofstd/ofcast.h" 00036 00037 #include "dcmtk/dcmimgle/dimoimg.h" 00038 #include "dcmtk/dcmimgle/didispfn.h" 00039 #include "dcmtk/dcmimgle/diutils.h" 00040 00041 00042 /*------------------------* 00043 * forward declarations * 00044 *------------------------*/ 00045 00046 class DcmXfer; 00047 class DcmObject; 00048 class DcmOverlayData; 00049 class DcmLongString; 00050 class DcmUnsignedShort; 00051 00052 class DiPixel; 00053 class DiDocument; 00054 class DiPluginFormat; 00055 00056 00057 /*---------------------* 00058 * class declaration * 00059 *---------------------*/ 00060 00064 class DicomImage 00065 { 00066 00067 public: 00068 00069 // --- constructors and destructor 00070 00081 DicomImage(const char *filename, 00082 const unsigned long flags = 0, 00083 const unsigned long fstart = 0, 00084 const unsigned long fcount = 0); 00085 00086 #ifndef STARVIEW 00087 00099 DicomImage(DcmObject *object, 00100 const E_TransferSyntax xfer, 00101 const unsigned long flags = 0, 00102 const unsigned long fstart = 0, 00103 const unsigned long fcount = 0); 00104 00121 DicomImage(DcmObject *object, 00122 const E_TransferSyntax xfer, 00123 const double slope, 00124 const double intercept, 00125 const unsigned long flags = 0, 00126 const unsigned long fstart = 0, 00127 const unsigned long fcount = 0); 00128 00146 DicomImage(DcmObject *object, 00147 E_TransferSyntax xfer, 00148 const DcmUnsignedShort &data, 00149 const DcmUnsignedShort &descriptor, 00150 const DcmLongString *explanation = NULL, 00151 const unsigned long flags = 0, 00152 const unsigned long fstart = 0, 00153 const unsigned long fcount = 0); 00154 #endif 00155 00158 virtual ~DicomImage(); 00159 00160 00161 // --- multi-frame handling 00162 00177 inline int processNextFrames(const unsigned long fcount = 0) 00178 { 00179 return (Image != NULL) ? 00180 Image->processNextFrames(fcount) : 0; 00181 } 00182 00183 00184 // --- information: return requested value if successful 00185 00192 static const char *getString(const EI_Status status); 00193 00200 static const char *getString(const EP_Interpretation interpret); 00201 00206 inline EI_Status getStatus() const 00207 { 00208 return (Image != NULL) ? 00209 Image->getStatus() : ImageStatus; 00210 } 00211 00219 inline unsigned long getFrameCount() const 00220 { 00221 return (Image != NULL) ? 00222 Image->getNumberOfFrames() : 0; 00223 } 00224 00231 inline unsigned long getFirstFrame() const 00232 { 00233 return (Image != NULL) ? 00234 Image->getFirstFrame() : 0; 00235 } 00236 00242 inline unsigned long getRepresentativeFrame() const 00243 { 00244 return (Image != NULL) ? 00245 Image->getRepresentativeFrame() : 0; 00246 } 00247 00252 inline unsigned long getWidth() const 00253 { 00254 return (Image != NULL) ? 00255 Image->getColumns() : 0; 00256 } 00257 00262 inline unsigned long getHeight() const 00263 { 00264 return (Image != NULL) ? 00265 Image->getRows() : 0; 00266 } 00267 00272 inline int getDepth() const 00273 { 00274 return (Image != NULL) ? 00275 Image->getBits() : 0; 00276 } 00277 00291 inline int getMinMaxValues(double &min, 00292 double &max, 00293 const int mode = 0) const 00294 { 00295 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00296 Image->getMonoImagePtr()->getMinMaxValues(min, max, mode) : 0; 00297 } 00298 00305 inline double getWidthHeightRatio() const 00306 { 00307 return (Image != NULL) ? 00308 Image->getColumnRowRatio() : 0; 00309 } 00310 00318 inline double getHeightWidthRatio() const 00319 { 00320 return (Image != NULL) ? 00321 Image->getRowColumnRatio() : 0; 00322 } 00323 00330 inline int setWidthHeightRatio(const double ratio) const 00331 { 00332 return (Image != NULL) ? 00333 Image->setColumnRowRatio(ratio) : 0; 00334 } 00335 00342 inline int setHeightWidthRatio(const double ratio) const 00343 { 00344 return (Image != NULL) ? 00345 Image->setRowColumnRatio(ratio) : 0; 00346 } 00347 00354 inline int isOutputValueUnused(const unsigned long value) 00355 { 00356 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00357 Image->getMonoImagePtr()->isValueUnused(value) : 0; 00358 } 00359 00360 // --- output: return pointer to output data if successful 00361 00373 inline unsigned long getOutputDataSize(const int bits = 0) const 00374 { 00375 return (Image != NULL) ? 00376 Image->getOutputDataSize(Image->getBits(bits)) : 0; 00377 } 00378 00397 inline const void *getOutputData(const int bits = 0, 00398 const unsigned long frame = 0, 00399 const int planar = 0) 00400 { 00401 return (Image != NULL) ? 00402 Image->getOutputData(frame, Image->getBits(bits), planar) : NULL; 00403 } 00404 00423 inline int getOutputData(void *buffer, 00424 const unsigned long size, 00425 const int bits = 0, 00426 const unsigned long frame = 0, 00427 const int planar = 0) 00428 { 00429 return (Image != NULL) ? 00430 Image->getOutputData(buffer, size, frame, Image->getBits(bits), planar) : 0; 00431 } 00432 00444 inline const void *getOutputPlane(const int plane) const 00445 { 00446 return (Image != NULL) ? 00447 Image->getOutputPlane(plane) : NULL; 00448 } 00449 00453 inline void deleteOutputData() const 00454 { 00455 if (Image != NULL) 00456 Image->deleteOutputData(); 00457 } 00458 00459 // --- misc 00460 00465 inline int isMonochrome() const 00466 { 00467 return (PhotometricInterpretation == EPI_Monochrome1) || (PhotometricInterpretation == EPI_Monochrome2); 00468 } 00469 00474 inline EP_Interpretation getPhotometricInterpretation() const 00475 { 00476 return PhotometricInterpretation; 00477 } 00478 00483 int hasSOPclassUID(const char *uid) const; 00484 00496 inline const DiPixel *getInterData() const 00497 { 00498 return (Image != NULL) ? 00499 Image->getInterData() : NULL; 00500 } 00501 00502 // --- display function for output device characteristic (calibration): 00503 // only applicable to grayscale images 00504 00509 inline DiDisplayFunction *getDisplayFunction() const 00510 { 00511 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00512 Image->getMonoImagePtr()->getDisplayFunction() : OFstatic_cast(DiDisplayFunction *, NULL); 00513 } 00514 00521 inline int setDisplayFunction(DiDisplayFunction *display) 00522 { 00523 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00524 Image->getMonoImagePtr()->setDisplayFunction(display) : 0; 00525 } 00526 00534 inline int setNoDisplayFunction() 00535 { 00536 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00537 Image->getMonoImagePtr()->setNoDisplayFunction() : 0; 00538 } 00539 00546 inline int deleteDisplayLUT(const int bits = 0) 00547 { 00548 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00549 Image->getMonoImagePtr()->deleteDisplayLUT(bits) : 0; 00550 } 00551 00563 inline int convertPValueToDDL(const Uint16 pvalue, 00564 Uint16 &ddl, 00565 const int bits = 8) 00566 { 00567 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00568 Image->getMonoImagePtr()->convertPValueToDDL(pvalue, ddl, bits) : 0; 00569 } 00570 00571 // --- windowing (voi): only applicable to grayscale images 00572 // return true if successful (see also 'dimoimg.cc') 00573 00581 inline int setNoVoiTransformation() 00582 { 00583 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00584 Image->getMonoImagePtr()->setNoVoiTransformation() : 0; 00585 } 00586 00598 inline int setMinMaxWindow(const int idx = 0) 00599 { 00600 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00601 Image->getMonoImagePtr()->setMinMaxWindow(idx) : 0; 00602 } 00603 00612 inline int setHistogramWindow(const double thresh = 0.05) 00613 { 00614 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00615 Image->getMonoImagePtr()->setHistogramWindow(thresh) : 0; 00616 } 00617 00634 inline int setRoiWindow(const unsigned long left_pos, 00635 const unsigned long top_pos, 00636 const unsigned long width, 00637 const unsigned long height, 00638 const unsigned long frame = 0) 00639 { 00640 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00641 Image->getMonoImagePtr()->setRoiWindow(left_pos, top_pos, width, height, frame) : 0; 00642 } 00643 00652 inline int setWindow(const unsigned long window) 00653 { 00654 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00655 Image->getMonoImagePtr()->setWindow(window) : 0; 00656 } 00657 00668 inline int setWindow(const double center, 00669 const double width) 00670 { 00671 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00672 Image->getMonoImagePtr()->setWindow(center, width) : 0; 00673 } 00674 00682 inline int getWindow(double ¢er, 00683 double &width) 00684 { 00685 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00686 Image->getMonoImagePtr()->getWindow(center, width) : 0; 00687 } 00688 00694 inline unsigned long getWindowCount() const 00695 { 00696 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00697 Image->getMonoImagePtr()->getWindowCount() : 0; 00698 } 00699 00710 inline int setVoiLutFunction(const EF_VoiLutFunction function) 00711 { 00712 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00713 Image->getMonoImagePtr()->setVoiLutFunction(function) : 0; 00714 } 00715 00722 inline EF_VoiLutFunction getVoiLutFunction() const 00723 { 00724 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00725 Image->getMonoImagePtr()->getVoiLutFunction() : EFV_Default; 00726 } 00727 00740 inline int setVoiLut(const DcmUnsignedShort &data, 00741 const DcmUnsignedShort &descriptor, 00742 const DcmLongString *explanation = NULL, 00743 const EL_BitsPerTableEntry descripMode = ELM_UseValue) 00744 { 00745 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00746 Image->getMonoImagePtr()->setVoiLut(data, descriptor, explanation, descripMode) : 0; 00747 } 00748 00758 inline int setVoiLut(const unsigned long table, 00759 const EL_BitsPerTableEntry descripMode = ELM_UseValue) 00760 { 00761 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00762 Image->getMonoImagePtr()->setVoiLut(table, descripMode) : 0; 00763 } 00764 00769 inline unsigned long getVoiLutCount() const 00770 { 00771 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00772 Image->getMonoImagePtr()->getVoiLutCount() : 0; 00773 } 00774 00779 inline const char *getVoiTransformationExplanation() const 00780 { 00781 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00782 Image->getMonoImagePtr()->getVoiTransformationExplanation() : OFstatic_cast(const char *, NULL); 00783 } 00784 00792 inline const char *getVoiWindowExplanation(const unsigned long window, 00793 OFString &explanation) const 00794 { 00795 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00796 Image->getMonoImagePtr()->getVoiWindowExplanation(window, explanation) : OFstatic_cast(const char *, NULL); 00797 } 00798 00806 inline const char *getVoiLutExplanation(const unsigned long table, 00807 OFString &explanation) const 00808 { 00809 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00810 Image->getMonoImagePtr()->getVoiLutExplanation(table, explanation) : OFstatic_cast(const char *, NULL); 00811 } 00812 00817 inline const char *getModalityLutExplanation() const 00818 { 00819 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00820 Image->getMonoImagePtr()->getModalityLutExplanation() : OFstatic_cast(const char *, NULL); 00821 } 00822 00823 // --- hardcopy parameters 00824 00830 inline EP_Polarity getPolarity() const 00831 { 00832 return (Image != NULL) ? 00833 Image->getPolarity() : EPP_Normal; 00834 } 00835 00844 inline int setPolarity(const EP_Polarity polarity) 00845 { 00846 return (Image != NULL) ? 00847 Image->setPolarity(polarity) : 0; 00848 } 00849 00863 inline int setHardcopyParameters(const unsigned int min, 00864 const unsigned int max, 00865 const unsigned int reflect, 00866 const unsigned int illumin) 00867 { 00868 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00869 Image->getMonoImagePtr()->setHardcopyParameters(min, max, reflect, illumin) : 0; 00870 } 00871 00872 // --- presentation LUT: only applicable to grayscale images 00873 00880 inline ES_PresentationLut getPresentationLutShape() const 00881 { 00882 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00883 Image->getMonoImagePtr()->getPresentationLutShape() : ESP_Default; 00884 } 00885 00897 inline int setPresentationLutShape(const ES_PresentationLut shape) 00898 { 00899 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00900 Image->getMonoImagePtr()->setPresentationLutShape(shape) : 0; 00901 } 00902 00915 inline int setPresentationLut(const DcmUnsignedShort &data, 00916 const DcmUnsignedShort &descriptor, 00917 const DcmLongString *explanation = NULL, 00918 const EL_BitsPerTableEntry descripMode = ELM_UseValue) 00919 { 00920 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00921 Image->getMonoImagePtr()->setPresentationLut(data, descriptor, explanation, descripMode) : 0; 00922 } 00923 00928 inline const char *getPresentationLutExplanation() const 00929 { 00930 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00931 Image->getMonoImagePtr()->getPresentationLutExplanation() : OFstatic_cast(const char *, NULL); 00932 } 00933 00944 inline int setInversePresentationLut(const DcmUnsignedShort &data, 00945 const DcmUnsignedShort &descriptor, 00946 const EL_BitsPerTableEntry descripMode = ELM_UseValue) 00947 { 00948 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00949 Image->getMonoImagePtr()->setInversePresentationLut(data, descriptor, descripMode) : 0; 00950 } 00951 00952 // --- overlays: return true (!0) if successful (see also 'diovlay.cc') 00953 // only applicable to grayscale images 00954 00971 inline int addOverlay(const unsigned int group, 00972 const signed int left_pos, 00973 const signed int top_pos, 00974 const unsigned int width, 00975 const unsigned int height, 00976 const DcmOverlayData &data, 00977 const DcmLongString &label, 00978 const DcmLongString &description, 00979 const EM_Overlay mode = EMO_Default) 00980 { 00981 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00982 Image->getMonoImagePtr()->addOverlay(group, left_pos, top_pos, width, height, data, label, description, mode) : 0; 00983 } 00984 00991 inline int removeOverlay(const unsigned int group) 00992 { 00993 return ((Image != NULL) && (Image->getOverlayPtr(1) != NULL)) ? 00994 Image->getOverlayPtr(1)->removePlane(group) : 0; 00995 } 00996 01002 inline int removeAllOverlays() 01003 { 01004 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 01005 Image->getMonoImagePtr()->removeAllOverlays() : 0; 01006 } 01007 01016 inline int isOverlayVisible(const unsigned int plane, 01017 const unsigned int idx = 0) 01018 { 01019 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01020 Image->getOverlayPtr(idx)->isPlaneVisible(plane) : 0; 01021 } 01022 01031 inline int showOverlay(const unsigned int plane, 01032 const unsigned int idx = 0) 01033 { 01034 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01035 Image->getOverlayPtr(idx)->showPlane(plane) : 0; 01036 } 01037 01048 inline int showOverlay(const unsigned int plane, 01049 const EM_Overlay mode, 01050 const double fore = 1.0, 01051 const double thresh = 0.5, 01052 const unsigned int idx = 0) 01053 { 01054 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01055 Image->getOverlayPtr(idx)->showPlane(plane, fore, thresh, mode) : 0; 01056 } 01057 01065 inline int showOverlay(const unsigned int plane, 01066 const Uint16 pvalue) 01067 { 01068 return ((Image != NULL) && (Image->getOverlayPtr(1) != NULL)) ? 01069 Image->getOverlayPtr(1)->showPlane(plane, pvalue) : 0; 01070 } 01071 01079 inline int showAllOverlays(const unsigned int idx = 0) 01080 { 01081 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01082 Image->getOverlayPtr(idx)->showAllPlanes() : 0; 01083 } 01084 01095 inline int showAllOverlays(const EM_Overlay mode, 01096 const double fore = 1, 01097 const double thresh = 0.5, 01098 const unsigned int idx = 0) 01099 { 01100 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01101 Image->getOverlayPtr(idx)->showAllPlanes(fore, thresh, mode) : 0; 01102 } 01103 01112 inline int hideOverlay(const unsigned int plane, 01113 const unsigned int idx = 0) 01114 { 01115 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01116 Image->getOverlayPtr(idx)->hidePlane(plane) : 0; 01117 } 01118 01126 inline int hideAllOverlays(const unsigned int idx = 0) 01127 { 01128 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01129 Image->getOverlayPtr(idx)->hideAllPlanes() : 0; 01130 } 01131 01142 inline int placeOverlay(const unsigned int plane, 01143 const signed int left_pos, 01144 const signed int top_pos, 01145 const unsigned int idx = 0) 01146 { 01147 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01148 Image->getOverlayPtr(idx)->placePlane(plane, left_pos, top_pos) : 0; 01149 } 01150 01157 inline unsigned int getOverlayCount(const unsigned int idx = 0) const 01158 { 01159 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01160 Image->getOverlayPtr(idx)->getCount() : 0; 01161 } 01162 01170 inline unsigned int getOverlayGroupNumber(const unsigned int plane, 01171 const unsigned int idx = 0) const 01172 { 01173 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01174 Image->getOverlayPtr(idx)->getPlaneGroupNumber(plane) : 0; 01175 } 01176 01184 inline const char *getOverlayLabel(const unsigned int plane, 01185 const unsigned int idx = 0) const 01186 { 01187 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01188 Image->getOverlayPtr(idx)->getPlaneLabel(plane) : OFstatic_cast(const char *, NULL); 01189 } 01190 01198 inline const char *getOverlayDescription(const unsigned int plane, 01199 const unsigned int idx = 0) const 01200 { 01201 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01202 Image->getOverlayPtr(idx)->getPlaneDescription(plane) : OFstatic_cast(const char *, NULL); 01203 } 01204 01212 inline EM_Overlay getOverlayMode(const unsigned int plane, 01213 const unsigned int idx = 0) const 01214 { 01215 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01216 Image->getOverlayPtr(idx)->getPlaneMode(plane) : EMO_Default; 01217 } 01218 01246 const void *getOverlayData(const unsigned int plane, 01247 unsigned int &left_pos, 01248 unsigned int &top_pos, 01249 unsigned int &width, 01250 unsigned int &height, 01251 EM_Overlay &mode, 01252 const unsigned long frame = 0, 01253 const int bits = 8, 01254 const Uint16 fore = 0xff, 01255 const Uint16 back = 0x0, 01256 const unsigned int idx = 2) const 01257 { 01258 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 01259 Image->getMonoImagePtr()->getOverlayData(frame, plane, left_pos, top_pos, width, height, mode, idx, bits, fore, back) : NULL; 01260 } 01261 01282 const void *getFullOverlayData(const unsigned int plane, 01283 unsigned int &width, 01284 unsigned int &height, 01285 const unsigned long frame = 0, 01286 const int bits = 8, 01287 const Uint16 fore = 0xff, 01288 const Uint16 back = 0x0, 01289 const unsigned int idx = 0) const 01290 { 01291 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 01292 Image->getMonoImagePtr()->getFullOverlayData(frame, plane, width, height, idx, bits, fore, back) : NULL; 01293 } 01294 01298 inline void deleteOverlayData() const 01299 { 01300 if ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) 01301 Image->getMonoImagePtr()->deleteOverlayData(); 01302 } 01303 01320 unsigned long create6xxx3000OverlayData(Uint8 *&buffer, 01321 const unsigned int plane, 01322 unsigned int &width, 01323 unsigned int &height, 01324 unsigned long &frames, 01325 const unsigned int idx = 0) const 01326 { 01327 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 01328 Image->getMonoImagePtr()->create6xxx3000OverlayData(buffer, plane, width, height, frames, idx) : 0; 01329 } 01330 01331 01332 // --- create...Image: return pointer to new 'DicomImage' object, memory isn't handled internally ! 01333 01342 DicomImage *createDicomImage(unsigned long fstart = 0, 01343 unsigned long fcount = 0) const; 01344 01360 DicomImage *createScaledImage(const unsigned long width, 01361 const unsigned long height = 0, 01362 const int interpolate = 0, 01363 int aspect = 0) const; 01364 01380 DicomImage *createScaledImage(const double xfactor, 01381 const double yfactor = 0, 01382 const int interpolate = 0, 01383 const int aspect = 0) const; 01384 01407 DicomImage *createScaledImage(const signed long left_pos, 01408 const signed long top_pos, 01409 unsigned long clip_width, 01410 unsigned long clip_height, 01411 unsigned long scale_width = 0, 01412 unsigned long scale_height = 0, 01413 const int interpolate = 0, 01414 int aspect = 0, 01415 const Uint16 pvalue = 0) const; 01416 01439 DicomImage *createScaledImage(const signed long left_pos, 01440 const signed long top_pos, 01441 unsigned long width, 01442 unsigned long height, 01443 const double xfactor, 01444 const double yfactor = 0, 01445 const int interpolate = 0, 01446 const int aspect = 0, 01447 const Uint16 pvalue = 0) const; 01448 01461 DicomImage *createClippedImage(const signed long left_pos, 01462 const signed long top_pos, 01463 unsigned long width = 0, 01464 unsigned long height = 0, 01465 const Uint16 pvalue = 0) const; 01466 01476 int flipImage(int horz = 1, 01477 int vert = 0) const; 01478 01487 DicomImage *createFlippedImage(int horz = 1, 01488 int vert = 0) const; 01489 01498 int rotateImage(signed int degree) const; 01499 01507 DicomImage *createRotatedImage(signed int degree) const; 01508 01520 DicomImage *createMonochromeImage(const double red = 0.299, 01521 const double green = 0.587, 01522 const double blue = 0.114) const; 01523 01548 unsigned long createWindowsDIB(void *&data, 01549 const unsigned long size, 01550 const unsigned long frame = 0, 01551 const int bits = 24, 01552 const int upsideDown = 0, 01553 const int padding = 1) 01554 { 01555 return (Image != NULL) ? 01556 Image->createDIB(data, size, frame, bits, upsideDown, padding) : 0; 01557 } 01558 01571 unsigned long createJavaAWTBitmap(void *&data, 01572 const unsigned long frame = 0, 01573 const int bits = 32) 01574 { 01575 return (Image != NULL) ? 01576 Image->createAWTBitmap(data, frame, bits) : 0; 01577 } 01578 01588 static void *create12BitPackedBitmap(const void *buffer, 01589 const unsigned long size, 01590 const unsigned long count) 01591 { 01592 return DiMonoImage::createPackedBitmap(buffer, size, count, 16, 12); 01593 } 01594 01604 DicomImage *createMonoOutputImage(const unsigned long frame, 01605 const int bits); 01606 01607 // --- output image file: return true ('1') if successful 01608 01636 inline int writeFrameToDataset(DcmItem &dataset, 01637 const int bits = 0, 01638 const unsigned long frame = 0, 01639 const int planar = 0) 01640 { 01641 return (Image != NULL) ? 01642 Image->writeFrameToDataset(dataset, frame, bits, planar) : 0; 01643 } 01644 01673 inline int writeImageToDataset(DcmItem &dataset, 01674 const int mode = 0, 01675 const int planar = 2) 01676 { 01677 return (Image != NULL) ? 01678 Image->writeImageToDataset(dataset, mode, planar) : 0; 01679 } 01680 01694 int writePPM(const char *filename, 01695 const int bits = 0, 01696 const unsigned long frame = 0); 01697 01711 int writePPM(STD_NAMESPACE ostream& stream, 01712 const int bits = 0, 01713 const unsigned long frame = 0); 01714 01728 int writePPM(FILE *stream, 01729 const int bits = 0, 01730 const unsigned long frame = 0); 01731 01745 int writeRawPPM(const char *filename, 01746 const int bits = 0, 01747 const unsigned long frame= 0); 01748 01762 int writeRawPPM(FILE *stream, 01763 const int bits = 0, 01764 const unsigned long frame = 0); 01765 01778 int writeBMP(FILE *stream, 01779 const int bits = 0, 01780 const unsigned long frame = 0); 01781 01794 int writeBMP(const char *filename, 01795 const int bits = 0, 01796 const unsigned long frame = 0); 01797 01807 int writePluginFormat(const DiPluginFormat *plugin, 01808 FILE *stream, 01809 const unsigned long frame = 0); 01810 01820 int writePluginFormat(const DiPluginFormat *plugin, 01821 const char *filename, 01822 const unsigned long frame = 0); 01823 01824 01825 protected: 01826 01833 DicomImage(const DicomImage *dicom, 01834 DiImage *image, 01835 const EP_Interpretation interpret = EPI_Unknown); 01836 01840 void Init(); 01841 01846 int checkDataDictionary(); 01847 01852 const char *getSOPclassUID() const; 01853 01862 int normalizeDegreeValue(signed int °ree) const; 01863 01864 01865 private: 01866 01868 EI_Status ImageStatus; 01870 EP_Interpretation PhotometricInterpretation; 01871 01873 DiDocument *Document; 01875 DiImage *Image; 01876 01877 // --- declarations to avoid compiler warnings 01878 01879 DicomImage(const DicomImage &); 01880 DicomImage &operator=(const DicomImage &); 01881 }; 01882 01883 01884 #endif 01885 01886 01887 /* 01888 * 01889 * CVS/RCS Log: 01890 * $Log: dcmimage.h,v $ 01891 * Revision 1.65 2010-10-14 13:16:25 joergr 01892 * Updated copyright header. Added reference to COPYRIGHT file. 01893 * 01894 * Revision 1.64 2010-10-05 15:24:02 joergr 01895 * Added preliminary support for VOI LUT function. Please note, however, that 01896 * the sigmoid transformation is not yet implemented. 01897 * 01898 * Revision 1.63 2010-03-02 09:23:32 joergr 01899 * Enhanced comments of some methods, e.g. processNextFrames(). 01900 * 01901 * Revision 1.62 2009-11-25 15:07:00 joergr 01902 * Added new method which allows for processing the frames of a multi-frame 01903 * image successively. The getString() method now returns the Defined Term of 01904 * the attribute PhotometricInterpretation. 01905 * 01906 * Revision 1.61 2009-02-12 12:03:56 joergr 01907 * Never update value of ImagerPixelSpacing when image is scaled, use 01908 * PixelSpacing instead. 01909 * Added support for NominalScannedPixelSpacing in order to determine the pixel 01910 * aspect ratio (used for the new SC image IODs). 01911 * 01912 * Revision 1.60 2008-07-11 08:35:28 joergr 01913 * Fixed typo in API documentation. 01914 * 01915 * Revision 1.59 2008-05-20 10:02:33 joergr 01916 * Added new bilinear and bicubic scaling algorithms for image magnification. 01917 * 01918 * Revision 1.58 2008-05-13 09:54:40 joergr 01919 * Added new parameter to writeImageToDataset() in order to affect the planar 01920 * configuration of the output image/dataset. Changed behaviour: By default, 01921 * the output now uses the same planar configuration as the "original" image 01922 * (previously: always color-by-plane). 01923 * 01924 * Revision 1.57 2007/03/16 11:56:05 joergr 01925 * Introduced new flag that allows to select how to handle the BitsPerTableEntry 01926 * value in the LUT descriptor (use, ignore or check). 01927 * 01928 * Revision 1.56 2006/08/15 16:30:11 meichel 01929 * Updated the code in module dcmimgle to correctly compile when 01930 * all standard C++ classes remain in namespace std. 01931 * 01932 * Revision 1.55 2006/07/10 10:52:27 joergr 01933 * Added support for 32-bit BMP images. 01934 * 01935 * Revision 1.54 2005/12/08 16:47:31 meichel 01936 * Changed include path schema for all DCMTK header files 01937 * 01938 * Revision 1.53 2005/03/09 17:33:40 joergr 01939 * Added mode to writeImageToDataset() which allows the value of BitsStored to 01940 * be determined either from 'used' or from 'possible' pixel values. 01941 * 01942 * Revision 1.52 2004/07/20 18:12:16 joergr 01943 * Added API method to "officially" access the internal intermediate pixel data 01944 * representation (e.g. to get Hounsfield Units for CT images). 01945 * 01946 * Revision 1.51 2003/12/17 16:17:29 joergr 01947 * Added new compatibility flag that allows to ignore the third value of LUT 01948 * descriptors and to determine the bits per table entry automatically. 01949 * 01950 * Revision 1.50 2003/12/11 17:22:19 joergr 01951 * Added comment to getOutputData/Plane() methods that the rendered pixel data 01952 * is always unsigned. 01953 * 01954 * Revision 1.49 2003/12/08 18:39:00 joergr 01955 * Adapted type casts to new-style typecast operators defined in ofcast.h. 01956 * Removed leading underscore characters from preprocessor symbols (reserved 01957 * symbols). Updated CVS header. 01958 * 01959 * Revision 1.48 2003/06/12 15:08:34 joergr 01960 * Fixed inconsistent API documentation reported by Doxygen. 01961 * 01962 * Revision 1.47 2003/05/20 09:24:31 joergr 01963 * Added method returning the number of bytes required to store a single 01964 * rendered frame: getOutputDataSize(). 01965 * 01966 * Revision 1.46 2002/12/09 13:32:50 joergr 01967 * Renamed parameter/local variable to avoid name clashes with global 01968 * declaration left and/or right (used for as iostream manipulators). 01969 * 01970 * Revision 1.45 2002/10/21 10:09:58 joergr 01971 * Slightly enhanced comments for getOutputData(). 01972 * 01973 * Revision 1.44 2002/08/21 09:51:43 meichel 01974 * Removed DicomImage and DiDocument constructors that take a DcmStream 01975 * parameter 01976 * 01977 * Revision 1.43 2002/08/02 15:02:34 joergr 01978 * Enhanced writeFrameToDataset() routine (remove out-data DICOM attributes 01979 * from the dataset). 01980 * Added function to write the current image (not only a selected frame) to a 01981 * DICOM dataset. 01982 * 01983 * Revision 1.42 2002/07/19 08:24:20 joergr 01984 * Enhanced/corrected comments. 01985 * 01986 * Revision 1.41 2002/07/05 10:37:47 joergr 01987 * Added comments. 01988 * 01989 * Revision 1.40 2002/06/26 16:00:25 joergr 01990 * Added support for polarity flag to color images. 01991 * Added new method to write a selected frame to a DICOM dataset (incl. required 01992 * attributes from the "Image Pixel Module"). 01993 * Added new methods to get the explanation string of stored VOI windows and 01994 * LUTs (not only of the currently selected VOI transformation). 01995 * 01996 * Revision 1.39 2002/01/29 17:05:49 joergr 01997 * Added optional flag to the "Windows DIB" methods allowing to switch off the 01998 * scanline padding. 01999 * 02000 * Revision 1.38 2001/11/27 18:18:20 joergr 02001 * Added support for plugable output formats in class DicomImage. First 02002 * implementation is JPEG. 02003 * 02004 * Revision 1.37 2001/11/19 12:54:29 joergr 02005 * Added parameter 'frame' to setRoiWindow(). 02006 * 02007 * Revision 1.36 2001/11/09 16:25:13 joergr 02008 * Added support for Window BMP file format. 02009 * Enhanced and renamed createTrueColorDIB() method. 02010 * 02011 * Revision 1.35 2001/09/28 13:00:55 joergr 02012 * Changed default behaviour of setMinMaxWindow(). 02013 * Added routines to get the currently active Polarity and PresentationLUTShape. 02014 * Added method setRoiWindow() which automatically calculates a min-max VOI 02015 * window for a specified rectangular region of the image. 02016 * Added method to extract embedded overlay planes from pixel data and store 02017 * them in group (6xxx,3000) format. 02018 * Added new flag (CIF_KeepYCbCrColorModel) which avoids conversion of YCbCr 02019 * color models to RGB. 02020 * 02021 * Revision 1.34 2001/06/20 15:12:49 joergr 02022 * Enhanced multi-frame support for command line tool 'dcm2pnm': extract all 02023 * or a range of frames with one call. 02024 * 02025 * Revision 1.33 2001/05/14 09:49:17 joergr 02026 * Added support for "1 bit output" of overlay planes; useful to extract 02027 * overlay planes from the pixel data and store them separately in the dataset. 02028 * 02029 * Revision 1.32 2001/05/10 16:46:26 joergr 02030 * Enhanced comments of some overlay related methods. 02031 * 02032 * Revision 1.31 2000/07/07 13:42:11 joergr 02033 * Added support for LIN OD presentation LUT shape. 02034 * 02035 * Revision 1.30 2000/06/07 14:30:26 joergr 02036 * Added method to set the image polarity (normal, reverse). 02037 * 02038 * Revision 1.29 2000/04/27 13:08:37 joergr 02039 * Dcmimgle library code now consistently uses ofConsole for error output. 02040 * 02041 * Revision 1.28 2000/03/08 16:24:13 meichel 02042 * Updated copyright header. 02043 * 02044 * Revision 1.27 2000/03/06 18:16:02 joergr 02045 * Removed inline specifier from a 'large' method (reported by Sun CC 4.2). 02046 * 02047 * Revision 1.26 1999/11/19 12:36:55 joergr 02048 * Added explicit type cast to avoid compiler warnings (reported by gcc 02049 * 2.7.2.1 on Linux). 02050 * 02051 * Revision 1.25 1999/10/20 10:32:05 joergr 02052 * Enhanced method getOverlayData to support 12 bit data for print. 02053 * 02054 * Revision 1.24 1999/10/06 13:26:08 joergr 02055 * Corrected creation of PrintBitmap pixel data: VOI windows should be applied 02056 * before clipping to avoid that the region outside the image (border) is also 02057 * windowed (this requires a new method in dcmimgle to create a DicomImage 02058 * with the grayscale transformations already applied). 02059 * 02060 * Revision 1.23 1999/09/17 12:06:17 joergr 02061 * Added/changed/completed DOC++ style comments in the header files. 02062 * 02063 * Revision 1.22 1999/09/10 08:45:17 joergr 02064 * Added support for CIELAB display function. 02065 * 02066 * Revision 1.21 1999/09/08 15:19:23 joergr 02067 * Completed implementation of setting inverse presentation LUT as needed 02068 * e.g. for DICOM print (invert 8->12 bits PLUT). 02069 * 02070 * Revision 1.20 1999/08/25 16:38:48 joergr 02071 * Allow clipping region to be outside the image (overlapping). 02072 * 02073 * Revision 1.19 1999/07/23 13:50:07 joergr 02074 * Added methods to set 'PixelAspectRatio'. 02075 * Added dummy method (no implementation yet) to create inverse LUTs. 02076 * Added method to create 12 bit packed bitmap data (used for grayscale print 02077 * storage). 02078 * Added method to return pointer to currently used display function. 02079 * Added new interpolation algorithm for scaling. 02080 * 02081 * Revision 1.18 1999/05/10 09:33:54 joergr 02082 * Moved dcm2pnm version definition from module dcmimgle to dcmimage. 02083 * 02084 * Revision 1.17 1999/05/03 11:09:27 joergr 02085 * Minor code purifications to keep Sun CC 2.0.1 quiet. 02086 * 02087 * Revision 1.16 1999/04/28 14:45:54 joergr 02088 * Added experimental support to create grayscale images with more than 256 02089 * shades of gray to be displayed on a consumer monitor (use pastel colors). 02090 * 02091 * Revision 1.15 1999/03/24 17:19:56 joergr 02092 * Added/Modified comments and formatting. 02093 * 02094 * Revision 1.14 1999/03/22 08:51:06 joergr 02095 * Added parameter to specify (transparent) background color for method 02096 * getOverlayData(). 02097 * Added/Changed comments. 02098 * 02099 * Revision 1.13 1999/03/03 11:43:39 joergr 02100 * Changed comments. 02101 * 02102 * Revision 1.12 1999/02/11 15:35:04 joergr 02103 * Added routine to check whether particular grayscale values are unused in 02104 * the output data. 02105 * 02106 * Revision 1.11 1999/02/09 14:21:08 meichel 02107 * Corrected const signatures of some ctor declarations 02108 * 02109 * Revision 1.10 1999/02/08 12:37:35 joergr 02110 * Changed implementation of removeAllOverlays(). 02111 * Added parameter 'idx' to some overlay methods to distinguish between 02112 * built-in and additional overlay planes. 02113 * 02114 * Revision 1.9 1999/02/05 16:42:22 joergr 02115 * Added optional parameter to method convertPValueToDDL to specify width 02116 * of output data (number of bits). 02117 * 02118 * Revision 1.8 1999/02/03 16:59:54 joergr 02119 * Added support for calibration according to Barten transformation (incl. 02120 * a DISPLAY file describing the monitor characteristic). 02121 * 02122 * Revision 1.7 1999/01/20 14:58:26 joergr 02123 * Added new output method to fill external memory buffer with rendered pixel 02124 * data. 02125 * 02126 * Revision 1.6 1999/01/11 09:31:20 joergr 02127 * Added parameter to method 'getMinMaxValues()' to return absolute minimum 02128 * and maximum values ('possible') in addition to actually 'used' pixel 02129 * values. 02130 * 02131 * Revision 1.5 1998/12/23 11:31:58 joergr 02132 * Changed order of parameters for addOverlay() and getOverlayData(). 02133 * 02134 * Revision 1.3 1998/12/16 16:26:17 joergr 02135 * Added explanation string to LUT class (retrieved from dataset). 02136 * Added explanation string for VOI transformations. 02137 * Added method to export overlay planes (create 8-bit bitmap). 02138 * Renamed 'setNoVoiLutTransformation' method ('Voi' instead of 'VOI'). 02139 * Removed several methods used for monochrome images only in base class 02140 * 'DiImage'. Introduced mechanism to use the methods directly. 02141 * 02142 * Revision 1.2 1998/12/14 17:14:07 joergr 02143 * Added methods to add and remove additional overlay planes (still untested). 02144 * Added methods to support overlay labels and descriptions. 02145 * 02146 * Revision 1.1 1998/11/27 14:50:00 joergr 02147 * Added copyright message. 02148 * Added methods to convert module defined enum types to strings. 02149 * Added methods to support presentation LUTs and shapes. 02150 * Moved type definitions to diutils.h. 02151 * Added constructors to use external modality transformations. 02152 * Added method to directly create java AWT bitmaps. 02153 * Added methods and constructors for flipping and rotating, changed for 02154 * scaling and clipping. 02155 * 02156 * Revision 1.12 1998/07/01 08:39:17 joergr 02157 * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional 02158 * options), e.g. add copy constructors. 02159 * 02160 * Revision 1.11 1998/06/25 08:50:09 joergr 02161 * Added compatibility mode to support ACR-NEMA images and wrong 02162 * palette attribute tags. 02163 * 02164 * Revision 1.10 1998/05/11 14:53:07 joergr 02165 * Added CVS/RCS header to each file. 02166 * 02167 * 02168 */