00001 /* 00002 * 00003 * Copyright (C) 1996-2005, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmimgle 00019 * 00020 * Author: Joerg Riesmeier 00021 * 00022 * Purpose: Provides main interface to the "DICOM image toolkit" 00023 * 00024 * Last Update: $Author: meichel $ 00025 * Update Date: $Date: 2005/12/08 16:47:31 $ 00026 * CVS/RCS Revision: $Revision: 1.54 $ 00027 * Status: $State: Exp $ 00028 * 00029 * CVS/RCS Log at end of file 00030 * 00031 */ 00032 00033 00034 #ifndef DCMIMAGE_H 00035 #define DCMIMAGE_H 00036 00037 #include "dcmtk/config/osconfig.h" 00038 00039 #include "dcmtk/ofstd/ofcast.h" 00040 00041 #include "dcmtk/dcmimgle/dimoimg.h" 00042 #include "dcmtk/dcmimgle/didispfn.h" 00043 #include "dcmtk/dcmimgle/diutils.h" 00044 00045 00046 /*------------------------* 00047 * forward declarations * 00048 *------------------------*/ 00049 00050 class DcmXfer; 00051 class DcmObject; 00052 class DcmOverlayData; 00053 class DcmLongString; 00054 class DcmUnsignedShort; 00055 00056 class DiPixel; 00057 class DiDocument; 00058 class DiPluginFormat; 00059 00060 00061 /*---------------------* 00062 * class declaration * 00063 *---------------------*/ 00064 00068 class DicomImage 00069 { 00070 00071 public: 00072 00073 // --- constructors and destructor 00074 00085 DicomImage(const char *filename, 00086 const unsigned long flags = 0, 00087 const unsigned long fstart = 0, 00088 const unsigned long fcount = 0); 00089 00090 #ifndef STARVIEW 00091 00103 DicomImage(DcmObject *object, 00104 const E_TransferSyntax xfer, 00105 const unsigned long flags = 0, 00106 const unsigned long fstart = 0, 00107 const unsigned long fcount = 0); 00108 00125 DicomImage(DcmObject *object, 00126 const E_TransferSyntax xfer, 00127 const double slope, 00128 const double intercept, 00129 const unsigned long flags = 0, 00130 const unsigned long fstart = 0, 00131 const unsigned long fcount = 0); 00132 00150 DicomImage(DcmObject *object, 00151 E_TransferSyntax xfer, 00152 const DcmUnsignedShort &data, 00153 const DcmUnsignedShort &descriptor, 00154 const DcmLongString *explanation = NULL, 00155 const unsigned long flags = 0, 00156 const unsigned long fstart = 0, 00157 const unsigned long fcount = 0); 00158 #endif 00159 00162 virtual ~DicomImage(); 00163 00164 00165 // --- information: return requested value if successful 00166 00173 static const char *getString(const EI_Status status); 00174 00181 static const char *getString(const EP_Interpretation interpret); 00182 00187 inline EI_Status getStatus() const 00188 { 00189 return (Image != NULL) ? 00190 Image->getStatus() : ImageStatus; 00191 } 00192 00200 inline unsigned long getFrameCount() const 00201 { 00202 return (Image != NULL) ? 00203 Image->getNumberOfFrames() : 0; 00204 } 00205 00212 inline unsigned long getFirstFrame() const 00213 { 00214 return (Image != NULL) ? 00215 Image->getFirstFrame() : 0; 00216 } 00217 00223 inline unsigned long getRepresentativeFrame() const 00224 { 00225 return (Image != NULL) ? 00226 Image->getRepresentativeFrame() : 0; 00227 } 00228 00233 inline unsigned long getWidth() const 00234 { 00235 return (Image != NULL) ? 00236 Image->getColumns() : 0; 00237 } 00238 00243 inline unsigned long getHeight() const 00244 { 00245 return (Image != NULL) ? 00246 Image->getRows() : 0; 00247 } 00248 00253 inline int getDepth() const 00254 { 00255 return (Image != NULL) ? 00256 Image->getBits() : 0; 00257 } 00258 00272 inline int getMinMaxValues(double &min, 00273 double &max, 00274 const int mode = 0) const 00275 { 00276 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00277 Image->getMonoImagePtr()->getMinMaxValues(min, max, mode) : 0; 00278 } 00279 00284 inline double getWidthHeightRatio() const 00285 { 00286 return (Image != NULL) ? 00287 Image->getColumnRowRatio() : 0; 00288 } 00289 00294 inline double getHeightWidthRatio() const 00295 { 00296 return (Image != NULL) ? 00297 Image->getRowColumnRatio() : 0; 00298 } 00299 00306 inline int setWidthHeightRatio(const double ratio) const 00307 { 00308 return (Image != NULL) ? 00309 Image->setColumnRowRatio(ratio) : 0; 00310 } 00311 00318 inline int setHeightWidthRatio(const double ratio) const 00319 { 00320 return (Image != NULL) ? 00321 Image->setRowColumnRatio(ratio) : 0; 00322 } 00323 00330 inline int isOutputValueUnused(const unsigned long value) 00331 { 00332 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00333 Image->getMonoImagePtr()->isValueUnused(value) : 0; 00334 } 00335 00336 // --- output: return pointer to output data if successful 00337 00349 inline unsigned long getOutputDataSize(const int bits = 0) const 00350 { 00351 return (Image != NULL) ? 00352 Image->getOutputDataSize(Image->getBits(bits)) : 0; 00353 } 00354 00373 inline const void *getOutputData(const int bits = 0, 00374 const unsigned long frame = 0, 00375 const int planar = 0) 00376 { 00377 return (Image != NULL) ? 00378 Image->getOutputData(frame, Image->getBits(bits), planar) : NULL; 00379 } 00380 00399 inline int getOutputData(void *buffer, 00400 const unsigned long size, 00401 const int bits = 0, 00402 const unsigned long frame = 0, 00403 const int planar = 0) 00404 { 00405 return (Image != NULL) ? 00406 Image->getOutputData(buffer, size, frame, Image->getBits(bits), planar) : 0; 00407 } 00408 00420 inline const void *getOutputPlane(const int plane) const 00421 { 00422 return (Image != NULL) ? 00423 Image->getOutputPlane(plane) : NULL; 00424 } 00425 00429 inline void deleteOutputData() const 00430 { 00431 if (Image != NULL) 00432 Image->deleteOutputData(); 00433 } 00434 00435 // --- misc 00436 00441 inline int isMonochrome() const 00442 { 00443 return (PhotometricInterpretation == EPI_Monochrome1) || (PhotometricInterpretation == EPI_Monochrome2); 00444 } 00445 00450 inline EP_Interpretation getPhotometricInterpretation() const 00451 { 00452 return PhotometricInterpretation; 00453 } 00454 00459 int hasSOPclassUID(const char *uid) const; 00460 00470 inline const DiPixel *getInterData() const 00471 { 00472 return (Image != NULL) ? 00473 Image->getInterData() : NULL; 00474 } 00475 00476 // --- display function for output device characteristic (calibration): 00477 // only applicable to grayscale images 00478 00483 inline DiDisplayFunction *getDisplayFunction() const 00484 { 00485 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00486 Image->getMonoImagePtr()->getDisplayFunction() : OFstatic_cast(DiDisplayFunction *, NULL); 00487 } 00488 00495 inline int setDisplayFunction(DiDisplayFunction *display) 00496 { 00497 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00498 Image->getMonoImagePtr()->setDisplayFunction(display) : 0; 00499 } 00500 00508 inline int setNoDisplayFunction() 00509 { 00510 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00511 Image->getMonoImagePtr()->setNoDisplayFunction() : 0; 00512 } 00513 00520 inline int deleteDisplayLUT(const int bits = 0) 00521 { 00522 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00523 Image->getMonoImagePtr()->deleteDisplayLUT(bits) : 0; 00524 } 00525 00537 inline int convertPValueToDDL(const Uint16 pvalue, 00538 Uint16 &ddl, 00539 const int bits = 8) 00540 { 00541 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00542 Image->getMonoImagePtr()->convertPValueToDDL(pvalue, ddl, bits) : 0; 00543 } 00544 00545 // --- windowing (voi): only applicable to grayscale images 00546 // return true if successful (see also 'dimoimg.cc') 00547 00555 inline int setNoVoiTransformation() 00556 { 00557 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00558 Image->getMonoImagePtr()->setNoVoiTransformation() : 0; 00559 } 00560 00572 inline int setMinMaxWindow(const int idx = 0) 00573 { 00574 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00575 Image->getMonoImagePtr()->setMinMaxWindow(idx) : 0; 00576 } 00577 00586 inline int setHistogramWindow(const double thresh = 0.05) 00587 { 00588 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00589 Image->getMonoImagePtr()->setHistogramWindow(thresh) : 0; 00590 } 00591 00608 inline int setRoiWindow(const unsigned long left_pos, 00609 const unsigned long top_pos, 00610 const unsigned long width, 00611 const unsigned long height, 00612 const unsigned long frame = 0) 00613 { 00614 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00615 Image->getMonoImagePtr()->setRoiWindow(left_pos, top_pos, width, height, frame) : 0; 00616 } 00617 00626 inline int setWindow(const unsigned long window) 00627 { 00628 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00629 Image->getMonoImagePtr()->setWindow(window) : 0; 00630 } 00631 00642 inline int setWindow(const double center, 00643 const double width) 00644 { 00645 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00646 Image->getMonoImagePtr()->setWindow(center, width) : 0; 00647 } 00648 00656 inline int getWindow(double ¢er, 00657 double &width) 00658 { 00659 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00660 Image->getMonoImagePtr()->getWindow(center, width) : 0; 00661 } 00662 00668 inline unsigned long getWindowCount() const 00669 { 00670 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00671 Image->getMonoImagePtr()->getWindowCount() : 0; 00672 } 00673 00687 inline int setVoiLut(const DcmUnsignedShort &data, 00688 const DcmUnsignedShort &descriptor, 00689 const DcmLongString *explanation = NULL, 00690 const OFBool ignoreDepth = OFFalse) 00691 { 00692 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00693 Image->getMonoImagePtr()->setVoiLut(data, descriptor, explanation, ignoreDepth) : 0; 00694 } 00695 00706 inline int setVoiLut(const unsigned long table, 00707 const OFBool ignoreDepth = OFFalse) 00708 { 00709 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00710 Image->getMonoImagePtr()->setVoiLut(table, ignoreDepth) : 0; 00711 } 00712 00717 inline unsigned long getVoiLutCount() const 00718 { 00719 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00720 Image->getMonoImagePtr()->getVoiLutCount() : 0; 00721 } 00722 00727 inline const char *getVoiTransformationExplanation() const 00728 { 00729 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00730 Image->getMonoImagePtr()->getVoiTransformationExplanation() : OFstatic_cast(const char *, NULL); 00731 } 00732 00740 inline const char *getVoiWindowExplanation(const unsigned long window, 00741 OFString &explanation) const 00742 { 00743 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00744 Image->getMonoImagePtr()->getVoiWindowExplanation(window, explanation) : OFstatic_cast(const char *, NULL); 00745 } 00746 00754 inline const char *getVoiLutExplanation(const unsigned long table, 00755 OFString &explanation) const 00756 { 00757 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00758 Image->getMonoImagePtr()->getVoiLutExplanation(table, explanation) : OFstatic_cast(const char *, NULL); 00759 } 00760 00765 inline const char *getModalityLutExplanation() const 00766 { 00767 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00768 Image->getMonoImagePtr()->getModalityLutExplanation() : OFstatic_cast(const char *, NULL); 00769 } 00770 00771 // --- hardcopy parameters 00772 00778 inline EP_Polarity getPolarity() const 00779 { 00780 return (Image != NULL) ? 00781 Image->getPolarity() : EPP_Normal; 00782 } 00783 00792 inline int setPolarity(const EP_Polarity polarity) 00793 { 00794 return (Image != NULL) ? 00795 Image->setPolarity(polarity) : 0; 00796 } 00797 00810 inline int setHardcopyParameters(const unsigned int min, 00811 const unsigned int max, 00812 const unsigned int reflect, 00813 const unsigned int illumin) 00814 { 00815 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00816 Image->getMonoImagePtr()->setHardcopyParameters(min, max, reflect, illumin) : 0; 00817 } 00818 00819 // --- presentation LUT: only applicable to grayscale images 00820 00827 inline ES_PresentationLut getPresentationLutShape() const 00828 { 00829 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00830 Image->getMonoImagePtr()->getPresentationLutShape() : ESP_Default; 00831 } 00832 00844 inline int setPresentationLutShape(const ES_PresentationLut shape) 00845 { 00846 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00847 Image->getMonoImagePtr()->setPresentationLutShape(shape) : 0; 00848 } 00849 00863 inline int setPresentationLut(const DcmUnsignedShort &data, 00864 const DcmUnsignedShort &descriptor, 00865 const DcmLongString *explanation = NULL, 00866 const OFBool ignoreDepth = OFFalse) 00867 { 00868 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00869 Image->getMonoImagePtr()->setPresentationLut(data, descriptor, explanation, ignoreDepth) : 0; 00870 } 00871 00876 inline const char *getPresentationLutExplanation() const 00877 { 00878 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00879 Image->getMonoImagePtr()->getPresentationLutExplanation() : OFstatic_cast(const char *, NULL); 00880 } 00881 00893 inline int setInversePresentationLut(const DcmUnsignedShort &data, 00894 const DcmUnsignedShort &descriptor, 00895 const OFBool ignoreDepth = OFFalse) 00896 { 00897 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00898 Image->getMonoImagePtr()->setInversePresentationLut(data, descriptor, ignoreDepth) : 0; 00899 } 00900 00901 // --- overlays: return true (!0) if successful (see also 'diovlay.cc') 00902 // only applicable to grayscale images 00903 00920 inline int addOverlay(const unsigned int group, 00921 const signed int left_pos, 00922 const signed int top_pos, 00923 const unsigned int width, 00924 const unsigned int height, 00925 const DcmOverlayData &data, 00926 const DcmLongString &label, 00927 const DcmLongString &description, 00928 const EM_Overlay mode = EMO_Default) 00929 { 00930 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00931 Image->getMonoImagePtr()->addOverlay(group, left_pos, top_pos, width, height, data, label, description, mode) : 0; 00932 } 00933 00940 inline int removeOverlay(const unsigned int group) 00941 { 00942 return ((Image != NULL) && (Image->getOverlayPtr(1) != NULL)) ? 00943 Image->getOverlayPtr(1)->removePlane(group) : 0; 00944 } 00945 00951 inline int removeAllOverlays() 00952 { 00953 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00954 Image->getMonoImagePtr()->removeAllOverlays() : 0; 00955 } 00956 00965 inline int isOverlayVisible(const unsigned int plane, 00966 const unsigned int idx = 0) 00967 { 00968 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 00969 Image->getOverlayPtr(idx)->isPlaneVisible(plane) : 0; 00970 } 00971 00980 inline int showOverlay(const unsigned int plane, 00981 const unsigned int idx = 0) 00982 { 00983 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 00984 Image->getOverlayPtr(idx)->showPlane(plane) : 0; 00985 } 00986 00997 inline int showOverlay(const unsigned int plane, 00998 const EM_Overlay mode, 00999 const double fore = 1.0, 01000 const double thresh = 0.5, 01001 const unsigned int idx = 0) 01002 { 01003 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01004 Image->getOverlayPtr(idx)->showPlane(plane, fore, thresh, mode) : 0; 01005 } 01006 01014 inline int showOverlay(const unsigned int plane, 01015 const Uint16 pvalue) 01016 { 01017 return ((Image != NULL) && (Image->getOverlayPtr(1) != NULL)) ? 01018 Image->getOverlayPtr(1)->showPlane(plane, pvalue) : 0; 01019 } 01020 01028 inline int showAllOverlays(const unsigned int idx = 0) 01029 { 01030 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01031 Image->getOverlayPtr(idx)->showAllPlanes() : 0; 01032 } 01033 01044 inline int showAllOverlays(const EM_Overlay mode, 01045 const double fore = 1, 01046 const double thresh = 0.5, 01047 const unsigned int idx = 0) 01048 { 01049 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01050 Image->getOverlayPtr(idx)->showAllPlanes(fore, thresh, mode) : 0; 01051 } 01052 01061 inline int hideOverlay(const unsigned int plane, 01062 const unsigned int idx = 0) 01063 { 01064 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01065 Image->getOverlayPtr(idx)->hidePlane(plane) : 0; 01066 } 01067 01075 inline int hideAllOverlays(const unsigned int idx = 0) 01076 { 01077 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01078 Image->getOverlayPtr(idx)->hideAllPlanes() : 0; 01079 } 01080 01091 inline int placeOverlay(const unsigned int plane, 01092 const signed int left_pos, 01093 const signed int top_pos, 01094 const unsigned int idx = 0) 01095 { 01096 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01097 Image->getOverlayPtr(idx)->placePlane(plane, left_pos, top_pos) : 0; 01098 } 01099 01106 inline unsigned int getOverlayCount(const unsigned int idx = 0) const 01107 { 01108 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01109 Image->getOverlayPtr(idx)->getCount() : 0; 01110 } 01111 01119 inline unsigned int getOverlayGroupNumber(const unsigned int plane, 01120 const unsigned int idx = 0) const 01121 { 01122 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01123 Image->getOverlayPtr(idx)->getPlaneGroupNumber(plane) : 0; 01124 } 01125 01133 inline const char *getOverlayLabel(const unsigned int plane, 01134 const unsigned int idx = 0) const 01135 { 01136 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01137 Image->getOverlayPtr(idx)->getPlaneLabel(plane) : OFstatic_cast(const char *, NULL); 01138 } 01139 01147 inline const char *getOverlayDescription(const unsigned int plane, 01148 const unsigned int idx = 0) const 01149 { 01150 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01151 Image->getOverlayPtr(idx)->getPlaneDescription(plane) : OFstatic_cast(const char *, NULL); 01152 } 01153 01161 inline EM_Overlay getOverlayMode(const unsigned int plane, 01162 const unsigned int idx = 0) const 01163 { 01164 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01165 Image->getOverlayPtr(idx)->getPlaneMode(plane) : EMO_Default; 01166 } 01167 01195 const void *getOverlayData(const unsigned int plane, 01196 unsigned int &left_pos, 01197 unsigned int &top_pos, 01198 unsigned int &width, 01199 unsigned int &height, 01200 EM_Overlay &mode, 01201 const unsigned long frame = 0, 01202 const int bits = 8, 01203 const Uint16 fore = 0xff, 01204 const Uint16 back = 0x0, 01205 const unsigned int idx = 2) const 01206 { 01207 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 01208 Image->getMonoImagePtr()->getOverlayData(frame, plane, left_pos, top_pos, width, height, mode, idx, bits, fore, back) : NULL; 01209 } 01210 01231 const void *getFullOverlayData(const unsigned int plane, 01232 unsigned int &width, 01233 unsigned int &height, 01234 const unsigned long frame = 0, 01235 const int bits = 8, 01236 const Uint16 fore = 0xff, 01237 const Uint16 back = 0x0, 01238 const unsigned int idx = 0) const 01239 { 01240 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 01241 Image->getMonoImagePtr()->getFullOverlayData(frame, plane, width, height, idx, bits, fore, back) : NULL; 01242 } 01243 01247 inline void deleteOverlayData() const 01248 { 01249 if ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) 01250 Image->getMonoImagePtr()->deleteOverlayData(); 01251 } 01252 01269 unsigned long create6xxx3000OverlayData(Uint8 *&buffer, 01270 const unsigned int plane, 01271 unsigned int &width, 01272 unsigned int &height, 01273 unsigned long &frames, 01274 const unsigned int idx = 0) const 01275 { 01276 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 01277 Image->getMonoImagePtr()->create6xxx3000OverlayData(buffer, plane, width, height, frames, idx) : 0; 01278 } 01279 01280 01281 // --- create...Image: return pointer to new 'DicomImage' object, memory isn't handled internally ! 01282 01291 DicomImage *createDicomImage(unsigned long fstart = 0, 01292 unsigned long fcount = 0) const; 01293 01307 DicomImage *createScaledImage(const unsigned long width, 01308 const unsigned long height = 0, 01309 const int interpolate = 0, 01310 int aspect = 0) const; 01311 01325 DicomImage *createScaledImage(const double xfactor, 01326 const double yfactor = 0, 01327 const int interpolate = 0, 01328 const int aspect = 0) const; 01329 01350 DicomImage *createScaledImage(const signed long left_pos, 01351 const signed long top_pos, 01352 unsigned long clip_width, 01353 unsigned long clip_height, 01354 unsigned long scale_width = 0, 01355 unsigned long scale_height = 0, 01356 const int interpolate = 0, 01357 int aspect = 0, 01358 const Uint16 pvalue = 0) const; 01359 01380 DicomImage *createScaledImage(const signed long left_pos, 01381 const signed long top_pos, 01382 unsigned long width, 01383 unsigned long height, 01384 const double xfactor, 01385 const double yfactor = 0, 01386 const int interpolate = 0, 01387 const int aspect = 0, 01388 const Uint16 pvalue = 0) const; 01389 01402 DicomImage *createClippedImage(const signed long left_pos, 01403 const signed long top_pos, 01404 unsigned long width = 0, 01405 unsigned long height = 0, 01406 const Uint16 pvalue = 0) const; 01407 01417 int flipImage(int horz = 1, 01418 int vert = 0) const; 01419 01428 DicomImage *createFlippedImage(int horz = 1, 01429 int vert = 0) const; 01430 01439 int rotateImage(signed int degree) const; 01440 01448 DicomImage *createRotatedImage(signed int degree) const; 01449 01461 DicomImage *createMonochromeImage(const double red = 0.299, 01462 const double green = 0.587, 01463 const double blue = 0.114) const; 01464 01489 unsigned long createWindowsDIB(void *&data, 01490 const unsigned long size, 01491 const unsigned long frame = 0, 01492 const int bits = 24, 01493 const int upsideDown = 0, 01494 const int padding = 1) 01495 { 01496 return (Image != NULL) ? 01497 Image->createDIB(data, size, frame, bits, upsideDown, padding) : 0; 01498 } 01499 01512 unsigned long createJavaAWTBitmap(void *&data, 01513 const unsigned long frame = 0, 01514 const int bits = 32) 01515 { 01516 return (Image != NULL) ? 01517 Image->createAWTBitmap(data, frame, bits) : 0; 01518 } 01519 01529 static void *create12BitPackedBitmap(const void *buffer, 01530 const unsigned long size, 01531 const unsigned long count) 01532 { 01533 return DiMonoImage::createPackedBitmap(buffer, size, count, 16, 12); 01534 } 01535 01545 DicomImage *createMonoOutputImage(const unsigned long frame, 01546 const int bits); 01547 01548 // --- output image file: return true ('1') if successful 01549 01577 inline int writeFrameToDataset(DcmItem &dataset, 01578 const int bits = 0, 01579 const unsigned long frame = 0, 01580 const int planar = 0) 01581 { 01582 return (Image != NULL) ? 01583 Image->writeFrameToDataset(dataset, frame, bits, planar) : 0; 01584 } 01585 01610 inline int writeImageToDataset(DcmItem &dataset, 01611 const int mode = 0) 01612 { 01613 return (Image != NULL) ? 01614 Image->writeImageToDataset(dataset, mode) : 0; 01615 } 01616 01630 int writePPM(const char *filename, 01631 const int bits = 0, 01632 const unsigned long frame = 0); 01633 01647 int writePPM(ostream &stream, 01648 const int bits = 0, 01649 const unsigned long frame = 0); 01650 01664 int writePPM(FILE *stream, 01665 const int bits = 0, 01666 const unsigned long frame = 0); 01667 01681 int writeRawPPM(const char *filename, 01682 const int bits = 0, 01683 const unsigned long frame= 0); 01684 01698 int writeRawPPM(FILE *stream, 01699 const int bits = 0, 01700 const unsigned long frame = 0); 01701 01714 int writeBMP(FILE *stream, 01715 const int bits = 0, 01716 const unsigned long frame = 0); 01717 01730 int writeBMP(const char *filename, 01731 const int bits = 0, 01732 const unsigned long frame = 0); 01733 01743 int writePluginFormat(const DiPluginFormat *plugin, 01744 FILE *stream, 01745 const unsigned long frame = 0); 01746 01756 int writePluginFormat(const DiPluginFormat *plugin, 01757 const char *filename, 01758 const unsigned long frame = 0); 01759 01760 01761 protected: 01762 01769 DicomImage(const DicomImage *dicom, 01770 DiImage *image, 01771 const EP_Interpretation interpret = EPI_Unknown); 01772 01776 void Init(); 01777 01782 int checkDataDictionary(); 01783 01788 const char *getSOPclassUID() const; 01789 01798 int normalizeDegreeValue(signed int °ree) const; 01799 01800 01801 private: 01802 01804 EI_Status ImageStatus; 01806 EP_Interpretation PhotometricInterpretation; 01807 01809 DiDocument *Document; 01811 DiImage *Image; 01812 01813 // --- declarations to avoid compiler warnings 01814 01815 DicomImage(const DicomImage &); 01816 DicomImage &operator=(const DicomImage &); 01817 }; 01818 01819 01820 #endif 01821 01822 01823 /* 01824 * 01825 * CVS/RCS Log: 01826 * $Log: dcmimage.h,v $ 01827 * Revision 1.54 2005/12/08 16:47:31 meichel 01828 * Changed include path schema for all DCMTK header files 01829 * 01830 * Revision 1.53 2005/03/09 17:33:40 joergr 01831 * Added mode to writeImageToDataset() which allows the value of BitsStored to 01832 * be determined either from 'used' or from 'possible' pixel values. 01833 * 01834 * Revision 1.52 2004/07/20 18:12:16 joergr 01835 * Added API method to "officially" access the internal intermediate pixel data 01836 * representation (e.g. to get Hounsfield Units for CT images). 01837 * 01838 * Revision 1.51 2003/12/17 16:17:29 joergr 01839 * Added new compatibility flag that allows to ignore the third value of LUT 01840 * descriptors and to determine the bits per table entry automatically. 01841 * 01842 * Revision 1.50 2003/12/11 17:22:19 joergr 01843 * Added comment to getOutputData/Plane() methods that the rendered pixel data 01844 * is always unsigned. 01845 * 01846 * Revision 1.49 2003/12/08 18:39:00 joergr 01847 * Adapted type casts to new-style typecast operators defined in ofcast.h. 01848 * Removed leading underscore characters from preprocessor symbols (reserved 01849 * symbols). Updated CVS header. 01850 * 01851 * Revision 1.48 2003/06/12 15:08:34 joergr 01852 * Fixed inconsistent API documentation reported by Doxygen. 01853 * 01854 * Revision 1.47 2003/05/20 09:24:31 joergr 01855 * Added method returning the number of bytes required to store a single 01856 * rendered frame: getOutputDataSize(). 01857 * 01858 * Revision 1.46 2002/12/09 13:32:50 joergr 01859 * Renamed parameter/local variable to avoid name clashes with global 01860 * declaration left and/or right (used for as iostream manipulators). 01861 * 01862 * Revision 1.45 2002/10/21 10:09:58 joergr 01863 * Slightly enhanced comments for getOutputData(). 01864 * 01865 * Revision 1.44 2002/08/21 09:51:43 meichel 01866 * Removed DicomImage and DiDocument constructors that take a DcmStream 01867 * parameter 01868 * 01869 * Revision 1.43 2002/08/02 15:02:34 joergr 01870 * Enhanced writeFrameToDataset() routine (remove out-data DICOM attributes 01871 * from the dataset). 01872 * Added function to write the current image (not only a selected frame) to a 01873 * DICOM dataset. 01874 * 01875 * Revision 1.42 2002/07/19 08:24:20 joergr 01876 * Enhanced/corrected comments. 01877 * 01878 * Revision 1.41 2002/07/05 10:37:47 joergr 01879 * Added comments. 01880 * 01881 * Revision 1.40 2002/06/26 16:00:25 joergr 01882 * Added support for polarity flag to color images. 01883 * Added new method to write a selected frame to a DICOM dataset (incl. required 01884 * attributes from the "Image Pixel Module"). 01885 * Added new methods to get the explanation string of stored VOI windows and 01886 * LUTs (not only of the currently selected VOI transformation). 01887 * 01888 * Revision 1.39 2002/01/29 17:05:49 joergr 01889 * Added optional flag to the "Windows DIB" methods allowing to switch off the 01890 * scanline padding. 01891 * 01892 * Revision 1.38 2001/11/27 18:18:20 joergr 01893 * Added support for plugable output formats in class DicomImage. First 01894 * implementation is JPEG. 01895 * 01896 * Revision 1.37 2001/11/19 12:54:29 joergr 01897 * Added parameter 'frame' to setRoiWindow(). 01898 * 01899 * Revision 1.36 2001/11/09 16:25:13 joergr 01900 * Added support for Window BMP file format. 01901 * Enhanced and renamed createTrueColorDIB() method. 01902 * 01903 * Revision 1.35 2001/09/28 13:00:55 joergr 01904 * Changed default behaviour of setMinMaxWindow(). 01905 * Added routines to get the currently active Polarity and PresentationLUTShape. 01906 * Added method setRoiWindow() which automatically calculates a min-max VOI 01907 * window for a specified rectangular region of the image. 01908 * Added method to extract embedded overlay planes from pixel data and store 01909 * them in group (6xxx,3000) format. 01910 * Added new flag (CIF_KeepYCbCrColorModel) which avoids conversion of YCbCr 01911 * color models to RGB. 01912 * 01913 * Revision 1.34 2001/06/20 15:12:49 joergr 01914 * Enhanced multi-frame support for command line tool 'dcm2pnm': extract all 01915 * or a range of frames with one call. 01916 * 01917 * Revision 1.33 2001/05/14 09:49:17 joergr 01918 * Added support for "1 bit output" of overlay planes; useful to extract 01919 * overlay planes from the pixel data and store them separately in the dataset. 01920 * 01921 * Revision 1.32 2001/05/10 16:46:26 joergr 01922 * Enhanced comments of some overlay related methods. 01923 * 01924 * Revision 1.31 2000/07/07 13:42:11 joergr 01925 * Added support for LIN OD presentation LUT shape. 01926 * 01927 * Revision 1.30 2000/06/07 14:30:26 joergr 01928 * Added method to set the image polarity (normal, reverse). 01929 * 01930 * Revision 1.29 2000/04/27 13:08:37 joergr 01931 * Dcmimgle library code now consistently uses ofConsole for error output. 01932 * 01933 * Revision 1.28 2000/03/08 16:24:13 meichel 01934 * Updated copyright header. 01935 * 01936 * Revision 1.27 2000/03/06 18:16:02 joergr 01937 * Removed inline specifier from a 'large' method (reported by Sun CC 4.2). 01938 * 01939 * Revision 1.26 1999/11/19 12:36:55 joergr 01940 * Added explicit type cast to avoid compiler warnings (reported by gcc 01941 * 2.7.2.1 on Linux). 01942 * 01943 * Revision 1.25 1999/10/20 10:32:05 joergr 01944 * Enhanced method getOverlayData to support 12 bit data for print. 01945 * 01946 * Revision 1.24 1999/10/06 13:26:08 joergr 01947 * Corrected creation of PrintBitmap pixel data: VOI windows should be applied 01948 * before clipping to avoid that the region outside the image (border) is also 01949 * windowed (this requires a new method in dcmimgle to create a DicomImage 01950 * with the grayscale transformations already applied). 01951 * 01952 * Revision 1.23 1999/09/17 12:06:17 joergr 01953 * Added/changed/completed DOC++ style comments in the header files. 01954 * 01955 * Revision 1.22 1999/09/10 08:45:17 joergr 01956 * Added support for CIELAB display function. 01957 * 01958 * Revision 1.21 1999/09/08 15:19:23 joergr 01959 * Completed implementation of setting inverse presentation LUT as needed 01960 * e.g. for DICOM print (invert 8->12 bits PLUT). 01961 * 01962 * Revision 1.20 1999/08/25 16:38:48 joergr 01963 * Allow clipping region to be outside the image (overlapping). 01964 * 01965 * Revision 1.19 1999/07/23 13:50:07 joergr 01966 * Added methods to set 'PixelAspectRatio'. 01967 * Added dummy method (no implementation yet) to create inverse LUTs. 01968 * Added method to create 12 bit packed bitmap data (used for grayscale print 01969 * storage). 01970 * Added method to return pointer to currently used display function. 01971 * Added new interpolation algorithm for scaling. 01972 * 01973 * Revision 1.18 1999/05/10 09:33:54 joergr 01974 * Moved dcm2pnm version definition from module dcmimgle to dcmimage. 01975 * 01976 * Revision 1.17 1999/05/03 11:09:27 joergr 01977 * Minor code purifications to keep Sun CC 2.0.1 quiet. 01978 * 01979 * Revision 1.16 1999/04/28 14:45:54 joergr 01980 * Added experimental support to create grayscale images with more than 256 01981 * shades of gray to be displayed on a consumer monitor (use pastel colors). 01982 * 01983 * Revision 1.15 1999/03/24 17:19:56 joergr 01984 * Added/Modified comments and formatting. 01985 * 01986 * Revision 1.14 1999/03/22 08:51:06 joergr 01987 * Added parameter to specify (transparent) background color for method 01988 * getOverlayData(). 01989 * Added/Changed comments. 01990 * 01991 * Revision 1.13 1999/03/03 11:43:39 joergr 01992 * Changed comments. 01993 * 01994 * Revision 1.12 1999/02/11 15:35:04 joergr 01995 * Added routine to check whether particular grayscale values are unused in 01996 * the output data. 01997 * 01998 * Revision 1.11 1999/02/09 14:21:08 meichel 01999 * Corrected const signatures of some ctor declarations 02000 * 02001 * Revision 1.10 1999/02/08 12:37:35 joergr 02002 * Changed implementation of removeAllOverlays(). 02003 * Added parameter 'idx' to some overlay methods to distinguish between 02004 * built-in and additional overlay planes. 02005 * 02006 * Revision 1.9 1999/02/05 16:42:22 joergr 02007 * Added optional parameter to method convertPValueToDDL to specify width 02008 * of output data (number of bits). 02009 * 02010 * Revision 1.8 1999/02/03 16:59:54 joergr 02011 * Added support for calibration according to Barten transformation (incl. 02012 * a DISPLAY file describing the monitor characteristic). 02013 * 02014 * Revision 1.7 1999/01/20 14:58:26 joergr 02015 * Added new output method to fill external memory buffer with rendered pixel 02016 * data. 02017 * 02018 * Revision 1.6 1999/01/11 09:31:20 joergr 02019 * Added parameter to method 'getMinMaxValues()' to return absolute minimum 02020 * and maximum values ('possible') in addition to actually 'used' pixel 02021 * values. 02022 * 02023 * Revision 1.5 1998/12/23 11:31:58 joergr 02024 * Changed order of parameters for addOverlay() and getOverlayData(). 02025 * 02026 * Revision 1.3 1998/12/16 16:26:17 joergr 02027 * Added explanation string to LUT class (retrieved from dataset). 02028 * Added explanation string for VOI transformations. 02029 * Added method to export overlay planes (create 8-bit bitmap). 02030 * Renamed 'setNoVoiLutTransformation' method ('Voi' instead of 'VOI'). 02031 * Removed several methods used for monochrome images only in base class 02032 * 'DiImage'. Introduced mechanism to use the methods directly. 02033 * 02034 * Revision 1.2 1998/12/14 17:14:07 joergr 02035 * Added methods to add and remove additional overlay planes (still untested). 02036 * Added methods to support overlay labels and descriptions. 02037 * 02038 * Revision 1.1 1998/11/27 14:50:00 joergr 02039 * Added copyright message. 02040 * Added methods to convert module defined enum types to strings. 02041 * Added methods to support presentation LUTs and shapes. 02042 * Moved type definitions to diutils.h. 02043 * Added constructors to use external modality transformations. 02044 * Added method to directly create java AWT bitmaps. 02045 * Added methods and constructors for flipping and rotating, changed for 02046 * scaling and clipping. 02047 * 02048 * Revision 1.12 1998/07/01 08:39:17 joergr 02049 * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional 02050 * options), e.g. add copy constructors. 02051 * 02052 * Revision 1.11 1998/06/25 08:50:09 joergr 02053 * Added compatibility mode to support ACR-NEMA images and wrong 02054 * palette attribute tags. 02055 * 02056 * Revision 1.10 1998/05/11 14:53:07 joergr 02057 * Added CVS/RCS header to each file. 02058 * 02059 * 02060 */