diimage.h

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: DicomImage (Header)
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:47:42 $
00026  *  CVS/RCS Revision: $Revision: 1.38 $
00027  *  Status:           $State: Exp $
00028  *
00029  *  CVS/RCS Log at end of file
00030  *
00031  */
00032 
00033 
00034 #ifndef DIIMAGE_H
00035 #define DIIMAGE_H
00036 
00037 #include "dcmtk/config/osconfig.h"
00038 #include "dcmtk/dcmdata/dctypes.h"
00039 #include "dcmtk/dcmdata/dcitem.h"
00040 
00041 #ifdef SUNCC
00042 #include "dcmtk/dcmimgle/didocu.h"
00043 #endif
00044 
00045 #include "dcmtk/dcmimgle/diovlay.h"
00046 #include "dcmtk/dcmimgle/diutils.h"
00047 
00048 #define INCLUDE_CSTDIO
00049 #include "dcmtk/ofstd/ofstdinc.h"
00050 
00051 #include "dcmtk/ofstd/ofstream.h"
00052 
00053 
00054 /*------------------------*
00055  *  forward declarations  *
00056  *------------------------*/
00057 
00058 class DcmPixelData;
00059 class DcmUnsignedShort;
00060 
00061 #ifndef SUNCC
00062  class DiDocument;
00063 #endif
00064 
00065 class DiPixel;
00066 class DiMonoImage;
00067 class DiInputPixel;
00068 
00069 
00070 /*---------------------*
00071  *  class declaration  *
00072  *---------------------*/
00073 
00076 class DiImage
00077 {
00078 
00079  public:
00080 
00087     DiImage(const DiDocument *docu,
00088             const EI_Status status,
00089             const int spp);
00090 
00093     virtual ~DiImage();
00094 
00099     inline EI_Status getStatus() const
00100     {
00101         return ImageStatus;
00102     }
00103 
00108     inline Uint32 getNumberOfFrames() const
00109     {
00110         return NumberOfFrames;
00111     }
00112 
00117     inline Uint32 getFirstFrame() const
00118     {
00119         return FirstFrame;
00120     }
00121 
00126     inline Uint32 getRepresentativeFrame() const
00127     {
00128         return RepresentativeFrame;
00129     }
00130 
00135     inline Uint16 getRows() const
00136     {
00137         return Rows;
00138     }
00139 
00144     inline Uint16 getColumns() const
00145     {
00146          return Columns;
00147     }
00148 
00153     inline double getPixelWidth() const
00154     {
00155         return (PixelWidth > 0) ? PixelWidth : 1;
00156     }
00157 
00162     inline double getPixelHeight() const
00163     {
00164         return (PixelHeight > 0) ? PixelHeight : 1;
00165     }
00166 
00171     inline double getRowColumnRatio() const
00172     {
00173         return getPixelHeight() / getPixelWidth();
00174     }
00175 
00180     inline double getColumnRowRatio() const
00181     {
00182         return getPixelWidth() / getPixelHeight();
00183     }
00184 
00191     int setRowColumnRatio(const double ratio);
00192 
00199     int setColumnRowRatio(const double ratio);
00200 
00206     inline EP_Polarity getPolarity() const
00207     {
00208         return Polarity;
00209     }
00210 
00219     int setPolarity(const EP_Polarity polarity);
00220 
00231     virtual int getBits(const int bits = 0) const
00232     {
00233         return ((bits < 1) || (bits > MAX_BITS)) ? BitsPerSample : bits;
00234     }
00235 
00241     virtual EP_Interpretation getInternalColorModel() const = 0;
00242 
00247     virtual const DiPixel *getInterData() const = 0;
00248 
00255     virtual unsigned long getOutputDataSize(const int bits = 0) const = 0;
00256 
00266     virtual const void *getOutputData(const unsigned long frame,
00267                                       const int bits,
00268                                       const int planar) = 0;
00269 
00281     virtual int getOutputData(void *buffer,
00282                               const unsigned long size,
00283                               const unsigned long frame,
00284                               const int bits,
00285                               const int planar) = 0;
00286 
00294     virtual const void *getOutputPlane(const int plane) const = 0;
00295 
00298     virtual void deleteOutputData() = 0;
00299 
00306     virtual DiOverlay *getOverlayPtr(const unsigned int /*idx*/)
00307     {
00308         return NULL;
00309     }
00310 
00315     virtual DiMonoImage *getMonoImagePtr()
00316     {
00317         return NULL;
00318     }
00319 
00327     virtual DiImage *createImage(const unsigned long fstart,
00328                                  const unsigned long fcount) const = 0;
00329 
00348     virtual DiImage *createScale(const signed long left_pos,
00349                                  const signed long top_pos,
00350                                  const unsigned long clip_width,
00351                                  const unsigned long clip_height,
00352                                  const unsigned long scale_width,
00353                                  const unsigned long scale_height,
00354                                  const int interpolate,
00355                                  const int aspect,
00356                                  const Uint16 pvalue) const = 0;
00357 
00365     virtual int flip(const int horz,
00366                      const int vert) = 0;
00367 
00375     virtual DiImage *createFlip(const int horz,
00376                                 const int vert) const = 0;
00377 
00384     virtual int rotate(const int degree);
00385 
00392     virtual DiImage *createRotate(const int degree) const = 0;
00393 
00402     virtual DiImage *createMono(const double red,
00403                                 const double green,
00404                                 const double blue) const = 0;
00405 
00417     virtual unsigned long createDIB(void *&data,
00418                                     const unsigned long size,
00419                                     const unsigned long frame,
00420                                     const int bits,
00421                                     const int upsideDown,
00422                                     const int padding = 1) = 0;
00423 
00432     virtual unsigned long createAWTBitmap(void *&data,
00433                                           const unsigned long frame,
00434                                           const int bits) = 0;
00435 
00445     int writeFrameToDataset(DcmItem &dataset,
00446                             const unsigned long frame = 0,
00447                             const int bits = 0,
00448                             const int planar = 0);
00449 
00457     virtual int writeImageToDataset(DcmItem &dataset,
00458                                     const int mode = 0) = 0;
00459 
00469     virtual int writePPM(ostream &stream,
00470                          const unsigned long frame,
00471                          const int bits) = 0;
00472 
00482     virtual int writePPM(FILE *stream,
00483                          const unsigned long frame,
00484                          const int bits) = 0;
00485 
00494     virtual int writeRawPPM(FILE *stream,
00495                             const unsigned long frame,
00496                             const int bits) = 0;
00497 
00506     virtual int writeBMP(FILE *stream,
00507                          const unsigned long frame,
00508                          const int bits);
00509 
00510 
00511  protected:
00512 
00518     DiImage(const DiDocument *docu,
00519             const EI_Status status);
00520 
00527     DiImage(const DiImage *image,
00528             const unsigned long fstart,
00529             const unsigned long fcount);
00530 
00538     DiImage(const DiImage *image,
00539             const Uint16 width,
00540             const Uint16 height,
00541             const int aspect = 0);
00542 
00548     DiImage(const DiImage *image,
00549             const int degree = 0);
00550 
00558     DiImage(const DiImage *image,
00559             const unsigned long frame,
00560             const int stored,
00561             const int alloc);
00562 
00565     void deleteInputData();
00566 
00569     void checkPixelExtension();
00570 
00576     void convertPixelData(/*const*/ DcmPixelData *pixel,
00577                           const int spp);
00578 
00586     virtual void updateImagePixelModuleAttributes(DcmItem &dataset);
00587 
00591     int detachPixelData();
00592 
00594     EI_Status ImageStatus;
00596     const DiDocument *Document;
00597 
00599     Uint32 FirstFrame;
00601     Uint32 NumberOfFrames;
00603     Uint32 TotalNumberOfFrames;
00605     Uint32 RepresentativeFrame;
00607     Uint16 Rows;
00609     Uint16 Columns;
00611     double PixelWidth;
00613     double PixelHeight;
00615     Uint16 BitsAllocated;
00617     Uint16 BitsStored;
00619     Uint16 HighBit;
00620 
00622     int BitsPerSample;
00623 
00625     EP_Polarity Polarity;
00626 
00628     int hasSignedRepresentation;
00630     int hasPixelSpacing;
00632     int hasImagerPixelSpacing;
00634     int hasPixelAspectRatio;
00636     int isOriginal;
00637 
00639     DiInputPixel *InputData;
00640 
00641  // --- declarations to avoid compiler warnings
00642 
00643     DiImage(const DiImage &);
00644     DiImage &operator=(const DiImage &);
00645 };
00646 
00647 
00648 #endif
00649 
00650 
00651 /*
00652  *
00653  * CVS/RCS Log:
00654  * $Log: diimage.h,v $
00655  * Revision 1.38  2005/12/08 16:47:42  meichel
00656  * Changed include path schema for all DCMTK header files
00657  *
00658  * Revision 1.37  2005/03/09 17:32:35  joergr
00659  * Added mode to writeImageToDataset() which allows the value of BitsStored to
00660  * be determined either from 'used' or from 'possible' pixel values.
00661  *
00662  * Revision 1.36  2004/09/22 11:33:14  joergr
00663  * Introduced new member variable "TotalNumberOfFrames".
00664  *
00665  * Revision 1.35  2004/07/20 18:12:16  joergr
00666  * Added API method to "officially" access the internal intermediate pixel data
00667  * representation (e.g. to get Hounsfield Units for CT images).
00668  *
00669  * Revision 1.34  2004/02/06 11:07:50  joergr
00670  * Distinguish more clearly between const and non-const access to pixel data.
00671  *
00672  * Revision 1.33  2004/01/05 14:52:20  joergr
00673  * Removed acknowledgements with e-mail addresses from CVS log.
00674  *
00675  * Revision 1.32  2003/12/08 18:22:26  joergr
00676  * Removed leading underscore characters from preprocessor symbols (reserved
00677  * symbols). Updated CVS header.
00678  *
00679  * Revision 1.31  2003/06/12 15:08:34  joergr
00680  * Fixed inconsistent API documentation reported by Doxygen.
00681  *
00682  * Revision 1.30  2003/05/20 09:20:41  joergr
00683  * Added method returning the number of bytes required to store a single
00684  * rendered frame: getOutputDataSize().
00685  *
00686  * Revision 1.29  2002/12/09 13:32:51  joergr
00687  * Renamed parameter/local variable to avoid name clashes with global
00688  * declaration left and/or right (used for as iostream manipulators).
00689  *
00690  * Revision 1.28  2002/11/27 14:08:04  meichel
00691  * Adapted module dcmimgle to use of new header file ofstdinc.h
00692  *
00693  * Revision 1.27  2002/11/26 14:48:32  joergr
00694  * Added Smallest/LargestImagePixelValue to the list of attributes to be
00695  * removed from a newly created dataset.
00696  *
00697  * Revision 1.26  2002/08/02 15:03:20  joergr
00698  * Enhanced writeFrameToDataset() routine (remove out-data DICOM attributes
00699  * from the dataset).
00700  * Added function to write the current image (not only a selected frame) to a
00701  * DICOM dataset.
00702  *
00703  * Revision 1.25  2002/06/26 16:01:55  joergr
00704  * Added support for polarity flag to color images.
00705  * Added new method to write a selected frame to a DICOM dataset (incl. required
00706  * attributes from the "Image Pixel Module").
00707  *
00708  * Revision 1.24  2002/04/16 13:53:11  joergr
00709  * Added configurable support for C++ ANSI standard includes (e.g. streams).
00710  *
00711  * Revision 1.23  2002/01/29 17:05:50  joergr
00712  * Added optional flag to the "Windows DIB" methods allowing to switch off the
00713  * scanline padding.
00714  *
00715  * Revision 1.22  2001/11/27 18:18:22  joergr
00716  * Added support for plugable output formats in class DicomImage. First
00717  * implementation is JPEG.
00718  *
00719  * Revision 1.21  2001/11/09 16:26:37  joergr
00720  * Added support for Window BMP file format.
00721  * Enhanced and renamed createTrueColorDIB() method.
00722  *
00723  * Revision 1.20  2001/06/20 15:12:49  joergr
00724  * Enhanced multi-frame support for command line tool 'dcm2pnm': extract all
00725  * or a range of frames with one call.
00726  *
00727  * Revision 1.19  2001/06/01 15:49:42  meichel
00728  * Updated copyright header
00729  *
00730  * Revision 1.18  2000/03/08 16:24:16  meichel
00731  * Updated copyright header.
00732  *
00733  * Revision 1.17  2000/02/02 11:02:38  joergr
00734  * Removed space characters before preprocessor directives.
00735  *
00736  * Revision 1.16  1999/10/06 13:28:21  joergr
00737  * Corrected creation of PrintBitmap pixel data: VOI windows should be applied
00738  * before clipping to avoid that the region outside the image (border) is also
00739  * windowed (this requires a new method in dcmimgle to create a DicomImage
00740  * with the grayscale transformations already applied).
00741  *
00742  * Revision 1.15  1999/09/17 12:12:18  joergr
00743  * Added/changed/completed DOC++ style comments in the header files.
00744  *
00745  * Revision 1.14  1999/08/25 16:39:31  joergr
00746  * Allow clipping region to be outside the image (overlapping).
00747  *
00748  * Revision 1.13  1999/07/23 13:53:00  joergr
00749  * Added support for attribute 'ImagerPixelSpacing'.
00750  * Added support for attribute 'RepresentativeFrameNumber'.
00751  * Added methods to set 'PixelAspectRatio'.
00752  *
00753  * Revision 1.12  1999/04/28 14:47:34  joergr
00754  * Added experimental support to create grayscale images with more than 256
00755  * shades of gray to be displayed on a consumer monitor (use pastel colors).
00756  *
00757  * Revision 1.11  1999/03/24 17:20:01  joergr
00758  * Added/Modified comments and formatting.
00759  *
00760  * Revision 1.10  1999/02/08 12:38:12  joergr
00761  * Added parameter 'idx' to some overlay methods to distinguish between
00762  * built-in and additional overlay planes.
00763  *
00764  * Revision 1.9  1999/02/03 17:01:45  joergr
00765  * Added BEGIN_EXTERN_C and END_EXTERN_C to some C includes.
00766  *
00767  * Revision 1.8  1999/01/20 14:59:37  joergr
00768  * Added new output method to fill external memory buffer with rendered pixel
00769  * data.
00770  *
00771  * Revision 1.7  1999/01/11 09:32:32  joergr
00772  * Removed method 'getMinMaxValues()' in class 'DicomImage'.
00773  *
00774  * Revision 1.6  1998/12/23 11:33:08  joergr
00775  * Corrected some typos and formatting.
00776  *
00777  * Revision 1.5  1998/12/22 14:03:53  joergr
00778  * Changed parameter declaration to avoid compiler warnings (hide parameter
00779  * name).
00780  *
00781  * Revision 1.4  1998/12/16 16:29:04  joergr
00782  * Removed several methods used for monochrome images only in base class
00783  * 'DiImage'. Introduced mechanism to use the methods directly.
00784  *
00785  * Revision 1.3  1998/12/14 17:17:29  joergr
00786  * Added methods to add and remove additional overlay planes (still untested).
00787  *
00788  * Revision 1.2  1998/11/30 12:24:07  joergr
00789  * Added const type qualifier to some parameters to avoid errors with MSVC5
00790  * (couldn't create instance of abstract class).
00791  *
00792  * Revision 1.1  1998/11/27 15:06:08  joergr
00793  * Added copyright message.
00794  * Added methods and constructors for flipping and rotating, changed for
00795  * scaling and clipping.
00796  * Added method to directly create java AWT bitmaps.
00797  * Renamed variable 'Status' to 'ImageStatus' because of possible conflicts
00798  * with X windows systems.
00799  * Added method to detach pixel data if it is no longer needed.
00800  * Added methods to support presentation LUTs and shapes.
00801  *
00802  * Revision 1.6  1998/07/01 08:39:21  joergr
00803  * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional
00804  * options), e.g. add copy constructors.
00805  *
00806  * Revision 1.5  1998/05/11 14:53:16  joergr
00807  * Added CVS/RCS header to each file.
00808  *
00809  *
00810  */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5