00001 /* 00002 * 00003 * Copyright (C) 1996-2003, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmimgle 00019 * 00020 * Author: Joerg Riesmeier 00021 * 00022 * Purpose: Provides main interface to the "DICOM image toolkit" 00023 * 00024 * Last Update: $Author: joergr $ 00025 * Update Date: $Date: 2003/12/17 16:17:29 $ 00026 * CVS/RCS Revision: $Revision: 1.51 $ 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 "osconfig.h" 00038 00039 #include "ofcast.h" 00040 00041 #include "dimoimg.h" 00042 #include "didispfn.h" 00043 #include "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 DiDocument; 00057 class DiPluginFormat; 00058 00059 00060 /*---------------------* 00061 * class declaration * 00062 *---------------------*/ 00063 00066 class DicomImage 00067 { 00068 00069 public: 00070 00071 // --- constructors and destructor 00072 00083 DicomImage(const char *filename, 00084 const unsigned long flags = 0, 00085 const unsigned long fstart = 0, 00086 const unsigned long fcount = 0); 00087 00088 #ifndef STARVIEW 00089 00101 DicomImage(DcmObject *object, 00102 const E_TransferSyntax xfer, 00103 const unsigned long flags = 0, 00104 const unsigned long fstart = 0, 00105 const unsigned long fcount = 0); 00106 00123 DicomImage(DcmObject *object, 00124 const E_TransferSyntax xfer, 00125 const double slope, 00126 const double intercept, 00127 const unsigned long flags = 0, 00128 const unsigned long fstart = 0, 00129 const unsigned long fcount = 0); 00130 00148 DicomImage(DcmObject *object, 00149 E_TransferSyntax xfer, 00150 const DcmUnsignedShort &data, 00151 const DcmUnsignedShort &descriptor, 00152 const DcmLongString *explanation = NULL, 00153 const unsigned long flags = 0, 00154 const unsigned long fstart = 0, 00155 const unsigned long fcount = 0); 00156 #endif 00157 00160 virtual ~DicomImage(); 00161 00162 00163 // --- information: return requested value if successful 00164 00171 static const char *getString(const EI_Status status); 00172 00179 static const char *getString(const EP_Interpretation interpret); 00180 00185 inline EI_Status getStatus() const 00186 { 00187 return (Image != NULL) ? 00188 Image->getStatus() : ImageStatus; 00189 } 00190 00198 inline unsigned long getFrameCount() const 00199 { 00200 return (Image != NULL) ? 00201 Image->getNumberOfFrames() : 0; 00202 } 00203 00210 inline unsigned long getFirstFrame() const 00211 { 00212 return (Image != NULL) ? 00213 Image->getFirstFrame() : 0; 00214 } 00215 00221 inline unsigned long getRepresentativeFrame() const 00222 { 00223 return (Image != NULL) ? 00224 Image->getRepresentativeFrame() : 0; 00225 } 00226 00231 inline unsigned long getWidth() const 00232 { 00233 return (Image != NULL) ? 00234 Image->getColumns() : 0; 00235 } 00236 00241 inline unsigned long getHeight() const 00242 { 00243 return (Image != NULL) ? 00244 Image->getRows() : 0; 00245 } 00246 00251 inline int getDepth() const 00252 { 00253 return (Image != NULL) ? 00254 Image->getBits() : 0; 00255 } 00256 00270 inline int getMinMaxValues(double &min, 00271 double &max, 00272 const int mode = 0) const 00273 { 00274 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00275 Image->getMonoImagePtr()->getMinMaxValues(min, max, mode) : 0; 00276 } 00277 00282 inline double getWidthHeightRatio() const 00283 { 00284 return (Image != NULL) ? 00285 Image->getColumnRowRatio() : 0; 00286 } 00287 00292 inline double getHeightWidthRatio() const 00293 { 00294 return (Image != NULL) ? 00295 Image->getRowColumnRatio() : 0; 00296 } 00297 00304 inline int setWidthHeightRatio(const double ratio) const 00305 { 00306 return (Image != NULL) ? 00307 Image->setColumnRowRatio(ratio) : 0; 00308 } 00309 00316 inline int setHeightWidthRatio(const double ratio) const 00317 { 00318 return (Image != NULL) ? 00319 Image->setRowColumnRatio(ratio) : 0; 00320 } 00321 00328 inline int isOutputValueUnused(const unsigned long value) 00329 { 00330 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00331 Image->getMonoImagePtr()->isValueUnused(value) : 0; 00332 } 00333 00334 // --- output: return pointer to output data if successful 00335 00347 inline unsigned long getOutputDataSize(const int bits = 0) const 00348 { 00349 return (Image != NULL) ? 00350 Image->getOutputDataSize(Image->getBits(bits)) : 0; 00351 } 00352 00371 inline const void *getOutputData(const int bits = 0, 00372 const unsigned long frame = 0, 00373 const int planar = 0) 00374 { 00375 return (Image != NULL) ? 00376 Image->getOutputData(frame, Image->getBits(bits), planar) : NULL; 00377 } 00378 00397 inline int getOutputData(void *buffer, 00398 const unsigned long size, 00399 const int bits = 0, 00400 const unsigned long frame = 0, 00401 const int planar = 0) 00402 { 00403 return (Image != NULL) ? 00404 Image->getOutputData(buffer, size, frame, Image->getBits(bits), planar) : 0; 00405 } 00406 00418 inline const void *getOutputPlane(const int plane) const 00419 { 00420 return (Image != NULL) ? 00421 Image->getOutputPlane(plane) : NULL; 00422 } 00423 00427 inline void deleteOutputData() const 00428 { 00429 if (Image != NULL) 00430 Image->deleteOutputData(); 00431 } 00432 00433 // --- misc 00434 00439 inline int isMonochrome() const 00440 { 00441 return (PhotometricInterpretation == EPI_Monochrome1) || (PhotometricInterpretation == EPI_Monochrome2); 00442 } 00443 00448 inline EP_Interpretation getPhotometricInterpretation() const 00449 { 00450 return PhotometricInterpretation; 00451 } 00452 00457 int hasSOPclassUID(const char *uid) const; 00458 00459 // --- display function for output device characteristic (calibration): 00460 // only applicable to grayscale images 00461 00466 inline DiDisplayFunction *getDisplayFunction() const 00467 { 00468 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00469 Image->getMonoImagePtr()->getDisplayFunction() : OFstatic_cast(DiDisplayFunction *, NULL); 00470 } 00471 00478 inline int setDisplayFunction(DiDisplayFunction *display) 00479 { 00480 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00481 Image->getMonoImagePtr()->setDisplayFunction(display) : 0; 00482 } 00483 00491 inline int setNoDisplayFunction() 00492 { 00493 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00494 Image->getMonoImagePtr()->setNoDisplayFunction() : 0; 00495 } 00496 00503 inline int deleteDisplayLUT(const int bits = 0) 00504 { 00505 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00506 Image->getMonoImagePtr()->deleteDisplayLUT(bits) : 0; 00507 } 00508 00520 inline int convertPValueToDDL(const Uint16 pvalue, 00521 Uint16 &ddl, 00522 const int bits = 8) 00523 { 00524 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00525 Image->getMonoImagePtr()->convertPValueToDDL(pvalue, ddl, bits) : 0; 00526 } 00527 00528 // --- windowing (voi): only applicable to grayscale images 00529 // return true if successful (see also 'dimoimg.cc') 00530 00538 inline int setNoVoiTransformation() 00539 { 00540 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00541 Image->getMonoImagePtr()->setNoVoiTransformation() : 0; 00542 } 00543 00555 inline int setMinMaxWindow(const int idx = 0) 00556 { 00557 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00558 Image->getMonoImagePtr()->setMinMaxWindow(idx) : 0; 00559 } 00560 00569 inline int setHistogramWindow(const double thresh = 0.05) 00570 { 00571 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00572 Image->getMonoImagePtr()->setHistogramWindow(thresh) : 0; 00573 } 00574 00591 inline int setRoiWindow(const unsigned long left_pos, 00592 const unsigned long top_pos, 00593 const unsigned long width, 00594 const unsigned long height, 00595 const unsigned long frame = 0) 00596 { 00597 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00598 Image->getMonoImagePtr()->setRoiWindow(left_pos, top_pos, width, height, frame) : 0; 00599 } 00600 00609 inline int setWindow(const unsigned long window) 00610 { 00611 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00612 Image->getMonoImagePtr()->setWindow(window) : 0; 00613 } 00614 00625 inline int setWindow(const double center, 00626 const double width) 00627 { 00628 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00629 Image->getMonoImagePtr()->setWindow(center, width) : 0; 00630 } 00631 00639 inline int getWindow(double ¢er, 00640 double &width) 00641 { 00642 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00643 Image->getMonoImagePtr()->getWindow(center, width) : 0; 00644 } 00645 00651 inline unsigned long getWindowCount() const 00652 { 00653 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00654 Image->getMonoImagePtr()->getWindowCount() : 0; 00655 } 00656 00670 inline int setVoiLut(const DcmUnsignedShort &data, 00671 const DcmUnsignedShort &descriptor, 00672 const DcmLongString *explanation = NULL, 00673 const OFBool ignoreDepth = OFFalse) 00674 { 00675 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00676 Image->getMonoImagePtr()->setVoiLut(data, descriptor, explanation, ignoreDepth) : 0; 00677 } 00678 00689 inline int setVoiLut(const unsigned long table, 00690 const OFBool ignoreDepth = OFFalse) 00691 { 00692 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00693 Image->getMonoImagePtr()->setVoiLut(table, ignoreDepth) : 0; 00694 } 00695 00700 inline unsigned long getVoiLutCount() const 00701 { 00702 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00703 Image->getMonoImagePtr()->getVoiLutCount() : 0; 00704 } 00705 00710 inline const char *getVoiTransformationExplanation() const 00711 { 00712 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00713 Image->getMonoImagePtr()->getVoiTransformationExplanation() : OFstatic_cast(const char *, NULL); 00714 } 00715 00723 inline const char *getVoiWindowExplanation(const unsigned long window, 00724 OFString &explanation) const 00725 { 00726 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00727 Image->getMonoImagePtr()->getVoiWindowExplanation(window, explanation) : OFstatic_cast(const char *, NULL); 00728 } 00729 00737 inline const char *getVoiLutExplanation(const unsigned long table, 00738 OFString &explanation) const 00739 { 00740 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00741 Image->getMonoImagePtr()->getVoiLutExplanation(table, explanation) : OFstatic_cast(const char *, NULL); 00742 } 00743 00748 inline const char *getModalityLutExplanation() const 00749 { 00750 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00751 Image->getMonoImagePtr()->getModalityLutExplanation() : OFstatic_cast(const char *, NULL); 00752 } 00753 00754 // --- hardcopy parameters 00755 00761 inline EP_Polarity getPolarity() const 00762 { 00763 return (Image != NULL) ? 00764 Image->getPolarity() : EPP_Normal; 00765 } 00766 00775 inline int setPolarity(const EP_Polarity polarity) 00776 { 00777 return (Image != NULL) ? 00778 Image->setPolarity(polarity) : 0; 00779 } 00780 00793 inline int setHardcopyParameters(const unsigned int min, 00794 const unsigned int max, 00795 const unsigned int reflect, 00796 const unsigned int illumin) 00797 { 00798 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00799 Image->getMonoImagePtr()->setHardcopyParameters(min, max, reflect, illumin) : 0; 00800 } 00801 00802 // --- presentation LUT: only applicable to grayscale images 00803 00810 inline ES_PresentationLut getPresentationLutShape() const 00811 { 00812 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00813 Image->getMonoImagePtr()->getPresentationLutShape() : ESP_Default; 00814 } 00815 00827 inline int setPresentationLutShape(const ES_PresentationLut shape) 00828 { 00829 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00830 Image->getMonoImagePtr()->setPresentationLutShape(shape) : 0; 00831 } 00832 00846 inline int setPresentationLut(const DcmUnsignedShort &data, 00847 const DcmUnsignedShort &descriptor, 00848 const DcmLongString *explanation = NULL, 00849 const OFBool ignoreDepth = OFFalse) 00850 { 00851 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00852 Image->getMonoImagePtr()->setPresentationLut(data, descriptor, explanation, ignoreDepth) : 0; 00853 } 00854 00859 inline const char *getPresentationLutExplanation() const 00860 { 00861 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00862 Image->getMonoImagePtr()->getPresentationLutExplanation() : OFstatic_cast(const char *, NULL); 00863 } 00864 00876 inline int setInversePresentationLut(const DcmUnsignedShort &data, 00877 const DcmUnsignedShort &descriptor, 00878 const OFBool ignoreDepth = OFFalse) 00879 { 00880 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00881 Image->getMonoImagePtr()->setInversePresentationLut(data, descriptor, ignoreDepth) : 0; 00882 } 00883 00884 // --- overlays: return true (!0) if successful (see also 'diovlay.cc') 00885 // only applicable to grayscale images 00886 00903 inline int addOverlay(const unsigned int group, 00904 const signed int left_pos, 00905 const signed int top_pos, 00906 const unsigned int width, 00907 const unsigned int height, 00908 const DcmOverlayData &data, 00909 const DcmLongString &label, 00910 const DcmLongString &description, 00911 const EM_Overlay mode = EMO_Default) 00912 { 00913 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00914 Image->getMonoImagePtr()->addOverlay(group, left_pos, top_pos, width, height, data, label, description, mode) : 0; 00915 } 00916 00923 inline int removeOverlay(const unsigned int group) 00924 { 00925 return ((Image != NULL) && (Image->getOverlayPtr(1) != NULL)) ? 00926 Image->getOverlayPtr(1)->removePlane(group) : 0; 00927 } 00928 00934 inline int removeAllOverlays() 00935 { 00936 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 00937 Image->getMonoImagePtr()->removeAllOverlays() : 0; 00938 } 00939 00948 inline int isOverlayVisible(const unsigned int plane, 00949 const unsigned int idx = 0) 00950 { 00951 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 00952 Image->getOverlayPtr(idx)->isPlaneVisible(plane) : 0; 00953 } 00954 00963 inline int showOverlay(const unsigned int plane, 00964 const unsigned int idx = 0) 00965 { 00966 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 00967 Image->getOverlayPtr(idx)->showPlane(plane) : 0; 00968 } 00969 00980 inline int showOverlay(const unsigned int plane, 00981 const EM_Overlay mode, 00982 const double fore = 1.0, 00983 const double thresh = 0.5, 00984 const unsigned int idx = 0) 00985 { 00986 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 00987 Image->getOverlayPtr(idx)->showPlane(plane, fore, thresh, mode) : 0; 00988 } 00989 00997 inline int showOverlay(const unsigned int plane, 00998 const Uint16 pvalue) 00999 { 01000 return ((Image != NULL) && (Image->getOverlayPtr(1) != NULL)) ? 01001 Image->getOverlayPtr(1)->showPlane(plane, pvalue) : 0; 01002 } 01003 01011 inline int showAllOverlays(const unsigned int idx = 0) 01012 { 01013 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01014 Image->getOverlayPtr(idx)->showAllPlanes() : 0; 01015 } 01016 01027 inline int showAllOverlays(const EM_Overlay mode, 01028 const double fore = 1, 01029 const double thresh = 0.5, 01030 const unsigned int idx = 0) 01031 { 01032 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01033 Image->getOverlayPtr(idx)->showAllPlanes(fore, thresh, mode) : 0; 01034 } 01035 01044 inline int hideOverlay(const unsigned int plane, 01045 const unsigned int idx = 0) 01046 { 01047 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01048 Image->getOverlayPtr(idx)->hidePlane(plane) : 0; 01049 } 01050 01058 inline int hideAllOverlays(const unsigned int idx = 0) 01059 { 01060 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01061 Image->getOverlayPtr(idx)->hideAllPlanes() : 0; 01062 } 01063 01074 inline int placeOverlay(const unsigned int plane, 01075 const signed int left_pos, 01076 const signed int top_pos, 01077 const unsigned int idx = 0) 01078 { 01079 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01080 Image->getOverlayPtr(idx)->placePlane(plane, left_pos, top_pos) : 0; 01081 } 01082 01089 inline unsigned int getOverlayCount(const unsigned int idx = 0) const 01090 { 01091 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01092 Image->getOverlayPtr(idx)->getCount() : 0; 01093 } 01094 01102 inline unsigned int getOverlayGroupNumber(const unsigned int plane, 01103 const unsigned int idx = 0) const 01104 { 01105 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01106 Image->getOverlayPtr(idx)->getPlaneGroupNumber(plane) : 0; 01107 } 01108 01116 inline const char *getOverlayLabel(const unsigned int plane, 01117 const unsigned int idx = 0) const 01118 { 01119 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01120 Image->getOverlayPtr(idx)->getPlaneLabel(plane) : OFstatic_cast(const char *, NULL); 01121 } 01122 01130 inline const char *getOverlayDescription(const unsigned int plane, 01131 const unsigned int idx = 0) const 01132 { 01133 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01134 Image->getOverlayPtr(idx)->getPlaneDescription(plane) : OFstatic_cast(const char *, NULL); 01135 } 01136 01144 inline EM_Overlay getOverlayMode(const unsigned int plane, 01145 const unsigned int idx = 0) const 01146 { 01147 return ((Image != NULL) && (Image->getOverlayPtr(idx) != NULL)) ? 01148 Image->getOverlayPtr(idx)->getPlaneMode(plane) : EMO_Default; 01149 } 01150 01178 const void *getOverlayData(const unsigned int plane, 01179 unsigned int &left_pos, 01180 unsigned int &top_pos, 01181 unsigned int &width, 01182 unsigned int &height, 01183 EM_Overlay &mode, 01184 const unsigned long frame = 0, 01185 const int bits = 8, 01186 const Uint16 fore = 0xff, 01187 const Uint16 back = 0x0, 01188 const unsigned int idx = 2) const 01189 { 01190 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 01191 Image->getMonoImagePtr()->getOverlayData(frame, plane, left_pos, top_pos, width, height, mode, idx, bits, fore, back) : NULL; 01192 } 01193 01214 const void *getFullOverlayData(const unsigned int plane, 01215 unsigned int &width, 01216 unsigned int &height, 01217 const unsigned long frame = 0, 01218 const int bits = 8, 01219 const Uint16 fore = 0xff, 01220 const Uint16 back = 0x0, 01221 const unsigned int idx = 0) const 01222 { 01223 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 01224 Image->getMonoImagePtr()->getFullOverlayData(frame, plane, width, height, idx, bits, fore, back) : NULL; 01225 } 01226 01230 inline void deleteOverlayData() const 01231 { 01232 if ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) 01233 Image->getMonoImagePtr()->deleteOverlayData(); 01234 } 01235 01252 unsigned long create6xxx3000OverlayData(Uint8 *&buffer, 01253 const unsigned int plane, 01254 unsigned int &width, 01255 unsigned int &height, 01256 unsigned long &frames, 01257 const unsigned int idx = 0) const 01258 { 01259 return ((Image != NULL) && (Image->getMonoImagePtr() != NULL)) ? 01260 Image->getMonoImagePtr()->create6xxx3000OverlayData(buffer, plane, width, height, frames, idx) : 0; 01261 } 01262 01263 01264 // --- create...Image: return pointer to new 'DicomImage' object, memory isn't handled internally ! 01265 01274 DicomImage *createDicomImage(unsigned long fstart = 0, 01275 unsigned long fcount = 0) const; 01276 01290 DicomImage *createScaledImage(const unsigned long width, 01291 const unsigned long height = 0, 01292 const int interpolate = 0, 01293 int aspect = 0) const; 01294 01308 DicomImage *createScaledImage(const double xfactor, 01309 const double yfactor = 0, 01310 const int interpolate = 0, 01311 const int aspect = 0) const; 01312 01333 DicomImage *createScaledImage(const signed long left_pos, 01334 const signed long top_pos, 01335 unsigned long clip_width, 01336 unsigned long clip_height, 01337 unsigned long scale_width = 0, 01338 unsigned long scale_height = 0, 01339 const int interpolate = 0, 01340 int aspect = 0, 01341 const Uint16 pvalue = 0) const; 01342 01363 DicomImage *createScaledImage(const signed long left_pos, 01364 const signed long top_pos, 01365 unsigned long width, 01366 unsigned long height, 01367 const double xfactor, 01368 const double yfactor = 0, 01369 const int interpolate = 0, 01370 const int aspect = 0, 01371 const Uint16 pvalue = 0) const; 01372 01385 DicomImage *createClippedImage(const signed long left_pos, 01386 const signed long top_pos, 01387 unsigned long width = 0, 01388 unsigned long height = 0, 01389 const Uint16 pvalue = 0) const; 01390 01400 int flipImage(int horz = 1, 01401 int vert = 0) const; 01402 01411 DicomImage *createFlippedImage(int horz = 1, 01412 int vert = 0) const; 01413 01422 int rotateImage(signed int degree) const; 01423 01431 DicomImage *createRotatedImage(signed int degree) const; 01432 01444 DicomImage *createMonochromeImage(const double red = 0.299, 01445 const double green = 0.587, 01446 const double blue = 0.114) const; 01447 01472 unsigned long createWindowsDIB(void *&data, 01473 const unsigned long size, 01474 const unsigned long frame = 0, 01475 const int bits = 24, 01476 const int upsideDown = 0, 01477 const int padding = 1) 01478 { 01479 return (Image != NULL) ? 01480 Image->createDIB(data, size, frame, bits, upsideDown, padding) : 0; 01481 } 01482 01495 unsigned long createJavaAWTBitmap(void *&data, 01496 const unsigned long frame = 0, 01497 const int bits = 32) 01498 { 01499 return (Image != NULL) ? 01500 Image->createAWTBitmap(data, frame, bits) : 0; 01501 } 01502 01512 static void *create12BitPackedBitmap(const void *buffer, 01513 const unsigned long size, 01514 const unsigned long count) 01515 { 01516 return DiMonoImage::createPackedBitmap(buffer, size, count, 16, 12); 01517 } 01518 01528 DicomImage *createMonoOutputImage(const unsigned long frame, 01529 const int bits); 01530 01531 // --- output image file: return true ('1') if successful 01532 01560 inline int writeFrameToDataset(DcmItem &dataset, 01561 const int bits = 0, 01562 const unsigned long frame = 0, 01563 const int planar = 0) 01564 { 01565 return (Image != NULL) ? 01566 Image->writeFrameToDataset(dataset, frame, bits, planar) : 0; 01567 } 01568 01590 inline int writeImageToDataset(DcmItem &dataset) 01591 { 01592 return (Image != NULL) ? 01593 Image->writeImageToDataset(dataset) : 0; 01594 } 01595 01609 int writePPM(const char *filename, 01610 const int bits = 0, 01611 const unsigned long frame = 0); 01612 01626 int writePPM(ostream &stream, 01627 const int bits = 0, 01628 const unsigned long frame = 0); 01629 01643 int writePPM(FILE *stream, 01644 const int bits = 0, 01645 const unsigned long frame = 0); 01646 01660 int writeRawPPM(const char *filename, 01661 const int bits = 0, 01662 const unsigned long frame= 0); 01663 01677 int writeRawPPM(FILE *stream, 01678 const int bits = 0, 01679 const unsigned long frame = 0); 01680 01693 int writeBMP(FILE *stream, 01694 const int bits = 0, 01695 const unsigned long frame = 0); 01696 01709 int writeBMP(const char *filename, 01710 const int bits = 0, 01711 const unsigned long frame = 0); 01712 01722 int writePluginFormat(const DiPluginFormat *plugin, 01723 FILE *stream, 01724 const unsigned long frame = 0); 01725 01735 int writePluginFormat(const DiPluginFormat *plugin, 01736 const char *filename, 01737 const unsigned long frame = 0); 01738 01739 01740 protected: 01741 01748 DicomImage(const DicomImage *dicom, 01749 DiImage *image, 01750 const EP_Interpretation interpret = EPI_Unknown); 01751 01755 void Init(); 01756 01761 int checkDataDictionary(); 01762 01767 const char *getSOPclassUID() const; 01768 01777 int normalizeDegreeValue(signed int °ree) const; 01778 01779 01780 private: 01781 01783 EI_Status ImageStatus; 01785 EP_Interpretation PhotometricInterpretation; 01786 01788 DiDocument *Document; 01790 DiImage *Image; 01791 01792 // --- declarations to avoid compiler warnings 01793 01794 DicomImage(const DicomImage &); 01795 DicomImage &operator=(const DicomImage &); 01796 }; 01797 01798 01799 #endif 01800 01801 01802 /* 01803 * 01804 * CVS/RCS Log: 01805 * $Log: dcmimage.h,v $ 01806 * Revision 1.51 2003/12/17 16:17:29 joergr 01807 * Added new compatibility flag that allows to ignore the third value of LUT 01808 * descriptors and to determine the bits per table entry automatically. 01809 * 01810 * Revision 1.50 2003/12/11 17:22:19 joergr 01811 * Added comment to getOutputData/Plane() methods that the rendered pixel data 01812 * is always unsigned. 01813 * 01814 * Revision 1.49 2003/12/08 18:39:00 joergr 01815 * Adapted type casts to new-style typecast operators defined in ofcast.h. 01816 * Removed leading underscore characters from preprocessor symbols (reserved 01817 * symbols). Updated CVS header. 01818 * 01819 * Revision 1.48 2003/06/12 15:08:34 joergr 01820 * Fixed inconsistent API documentation reported by Doxygen. 01821 * 01822 * Revision 1.47 2003/05/20 09:24:31 joergr 01823 * Added method returning the number of bytes required to store a single 01824 * rendered frame: getOutputDataSize(). 01825 * 01826 * Revision 1.46 2002/12/09 13:32:50 joergr 01827 * Renamed parameter/local variable to avoid name clashes with global 01828 * declaration left and/or right (used for as iostream manipulators). 01829 * 01830 * Revision 1.45 2002/10/21 10:09:58 joergr 01831 * Slightly enhanced comments for getOutputData(). 01832 * 01833 * Revision 1.44 2002/08/21 09:51:43 meichel 01834 * Removed DicomImage and DiDocument constructors that take a DcmStream 01835 * parameter 01836 * 01837 * Revision 1.43 2002/08/02 15:02:34 joergr 01838 * Enhanced writeFrameToDataset() routine (remove out-data DICOM attributes 01839 * from the dataset). 01840 * Added function to write the current image (not only a selected frame) to a 01841 * DICOM dataset. 01842 * 01843 * Revision 1.42 2002/07/19 08:24:20 joergr 01844 * Enhanced/corrected comments. 01845 * 01846 * Revision 1.41 2002/07/05 10:37:47 joergr 01847 * Added comments. 01848 * 01849 * Revision 1.40 2002/06/26 16:00:25 joergr 01850 * Added support for polarity flag to color images. 01851 * Added new method to write a selected frame to a DICOM dataset (incl. required 01852 * attributes from the "Image Pixel Module"). 01853 * Added new methods to get the explanation string of stored VOI windows and 01854 * LUTs (not only of the currently selected VOI transformation). 01855 * 01856 * Revision 1.39 2002/01/29 17:05:49 joergr 01857 * Added optional flag to the "Windows DIB" methods allowing to switch off the 01858 * scanline padding. 01859 * 01860 * Revision 1.38 2001/11/27 18:18:20 joergr 01861 * Added support for plugable output formats in class DicomImage. First 01862 * implementation is JPEG. 01863 * 01864 * Revision 1.37 2001/11/19 12:54:29 joergr 01865 * Added parameter 'frame' to setRoiWindow(). 01866 * 01867 * Revision 1.36 2001/11/09 16:25:13 joergr 01868 * Added support for Window BMP file format. 01869 * Enhanced and renamed createTrueColorDIB() method. 01870 * 01871 * Revision 1.35 2001/09/28 13:00:55 joergr 01872 * Changed default behaviour of setMinMaxWindow(). 01873 * Added routines to get the currently active Polarity and PresentationLUTShape. 01874 * Added method setRoiWindow() which automatically calculates a min-max VOI 01875 * window for a specified rectangular region of the image. 01876 * Added method to extract embedded overlay planes from pixel data and store 01877 * them in group (6xxx,3000) format. 01878 * Added new flag (CIF_KeepYCbCrColorModel) which avoids conversion of YCbCr 01879 * color models to RGB. 01880 * 01881 * Revision 1.34 2001/06/20 15:12:49 joergr 01882 * Enhanced multi-frame support for command line tool 'dcm2pnm': extract all 01883 * or a range of frames with one call. 01884 * 01885 * Revision 1.33 2001/05/14 09:49:17 joergr 01886 * Added support for "1 bit output" of overlay planes; useful to extract 01887 * overlay planes from the pixel data and store them separately in the dataset. 01888 * 01889 * Revision 1.32 2001/05/10 16:46:26 joergr 01890 * Enhanced comments of some overlay related methods. 01891 * 01892 * Revision 1.31 2000/07/07 13:42:11 joergr 01893 * Added support for LIN OD presentation LUT shape. 01894 * 01895 * Revision 1.30 2000/06/07 14:30:26 joergr 01896 * Added method to set the image polarity (normal, reverse). 01897 * 01898 * Revision 1.29 2000/04/27 13:08:37 joergr 01899 * Dcmimgle library code now consistently uses ofConsole for error output. 01900 * 01901 * Revision 1.28 2000/03/08 16:24:13 meichel 01902 * Updated copyright header. 01903 * 01904 * Revision 1.27 2000/03/06 18:16:02 joergr 01905 * Removed inline specifier from a 'large' method (reported by Sun CC 4.2). 01906 * 01907 * Revision 1.26 1999/11/19 12:36:55 joergr 01908 * Added explicit type cast to avoid compiler warnings (reported by gcc 01909 * 2.7.2.1 on Linux). 01910 * 01911 * Revision 1.25 1999/10/20 10:32:05 joergr 01912 * Enhanced method getOverlayData to support 12 bit data for print. 01913 * 01914 * Revision 1.24 1999/10/06 13:26:08 joergr 01915 * Corrected creation of PrintBitmap pixel data: VOI windows should be applied 01916 * before clipping to avoid that the region outside the image (border) is also 01917 * windowed (this requires a new method in dcmimgle to create a DicomImage 01918 * with the grayscale transformations already applied). 01919 * 01920 * Revision 1.23 1999/09/17 12:06:17 joergr 01921 * Added/changed/completed DOC++ style comments in the header files. 01922 * 01923 * Revision 1.22 1999/09/10 08:45:17 joergr 01924 * Added support for CIELAB display function. 01925 * 01926 * Revision 1.21 1999/09/08 15:19:23 joergr 01927 * Completed implementation of setting inverse presentation LUT as needed 01928 * e.g. for DICOM print (invert 8->12 bits PLUT). 01929 * 01930 * Revision 1.20 1999/08/25 16:38:48 joergr 01931 * Allow clipping region to be outside the image (overlapping). 01932 * 01933 * Revision 1.19 1999/07/23 13:50:07 joergr 01934 * Added methods to set 'PixelAspectRatio'. 01935 * Added dummy method (no implementation yet) to create inverse LUTs. 01936 * Added method to create 12 bit packed bitmap data (used for grayscale print 01937 * storage). 01938 * Added method to return pointer to currently used display function. 01939 * Added new interpolation algorithm for scaling. 01940 * 01941 * Revision 1.18 1999/05/10 09:33:54 joergr 01942 * Moved dcm2pnm version definition from module dcmimgle to dcmimage. 01943 * 01944 * Revision 1.17 1999/05/03 11:09:27 joergr 01945 * Minor code purifications to keep Sun CC 2.0.1 quiet. 01946 * 01947 * Revision 1.16 1999/04/28 14:45:54 joergr 01948 * Added experimental support to create grayscale images with more than 256 01949 * shades of gray to be displayed on a consumer monitor (use pastel colors). 01950 * 01951 * Revision 1.15 1999/03/24 17:19:56 joergr 01952 * Added/Modified comments and formatting. 01953 * 01954 * Revision 1.14 1999/03/22 08:51:06 joergr 01955 * Added parameter to specify (transparent) background color for method 01956 * getOverlayData(). 01957 * Added/Changed comments. 01958 * 01959 * Revision 1.13 1999/03/03 11:43:39 joergr 01960 * Changed comments. 01961 * 01962 * Revision 1.12 1999/02/11 15:35:04 joergr 01963 * Added routine to check whether particular grayscale values are unused in 01964 * the output data. 01965 * 01966 * Revision 1.11 1999/02/09 14:21:08 meichel 01967 * Corrected const signatures of some ctor declarations 01968 * 01969 * Revision 1.10 1999/02/08 12:37:35 joergr 01970 * Changed implementation of removeAllOverlays(). 01971 * Added parameter 'idx' to some overlay methods to distinguish between 01972 * built-in and additional overlay planes. 01973 * 01974 * Revision 1.9 1999/02/05 16:42:22 joergr 01975 * Added optional parameter to method convertPValueToDDL to specify width 01976 * of output data (number of bits). 01977 * 01978 * Revision 1.8 1999/02/03 16:59:54 joergr 01979 * Added support for calibration according to Barten transformation (incl. 01980 * a DISPLAY file describing the monitor characteristic). 01981 * 01982 * Revision 1.7 1999/01/20 14:58:26 joergr 01983 * Added new output method to fill external memory buffer with rendered pixel 01984 * data. 01985 * 01986 * Revision 1.6 1999/01/11 09:31:20 joergr 01987 * Added parameter to method 'getMinMaxValues()' to return absolute minimum 01988 * and maximum values ('possible') in addition to actually 'used' pixel 01989 * values. 01990 * 01991 * Revision 1.5 1998/12/23 11:31:58 joergr 01992 * Changed order of parameters for addOverlay() and getOverlayData(). 01993 * 01994 * Revision 1.3 1998/12/16 16:26:17 joergr 01995 * Added explanation string to LUT class (retrieved from dataset). 01996 * Added explanation string for VOI transformations. 01997 * Added method to export overlay planes (create 8-bit bitmap). 01998 * Renamed 'setNoVoiLutTransformation' method ('Voi' instead of 'VOI'). 01999 * Removed several methods used for monochrome images only in base class 02000 * 'DiImage'. Introduced mechanism to use the methods directly. 02001 * 02002 * Revision 1.2 1998/12/14 17:14:07 joergr 02003 * Added methods to add and remove additional overlay planes (still untested). 02004 * Added methods to support overlay labels and descriptions. 02005 * 02006 * Revision 1.1 1998/11/27 14:50:00 joergr 02007 * Added copyright message. 02008 * Added methods to convert module defined enum types to strings. 02009 * Added methods to support presentation LUTs and shapes. 02010 * Moved type definitions to diutils.h. 02011 * Added constructors to use external modality transformations. 02012 * Added method to directly create java AWT bitmaps. 02013 * Added methods and constructors for flipping and rotating, changed for 02014 * scaling and clipping. 02015 * 02016 * Revision 1.12 1998/07/01 08:39:17 joergr 02017 * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional 02018 * options), e.g. add copy constructors. 02019 * 02020 * Revision 1.11 1998/06/25 08:50:09 joergr 02021 * Added compatibility mode to support ACR-NEMA images and wrong 02022 * palette attribute tags. 02023 * 02024 * Revision 1.10 1998/05/11 14:53:07 joergr 02025 * Added CVS/RCS header to each file. 02026 * 02027 * 02028 */