Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

diimage.h

00001 /*
00002  *
00003  *  Copyright (C) 1996-2004, 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: joergr $
00025  *  Update Date:      $Date: 2004/02/06 11:07:50 $
00026  *  CVS/RCS Revision: $Revision: 1.34 $
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 "osconfig.h"
00038 #include "dctypes.h"
00039 #include "dcitem.h"
00040 
00041 #ifdef SUNCC
00042 #include "didocu.h"
00043 #endif
00044 
00045 #include "diovlay.h"
00046 #include "diutils.h"
00047 
00048 #define INCLUDE_CSTDIO
00049 #include "ofstdinc.h"
00050 
00051 #include "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 DiMonoImage;
00066 class DiInputPixel;
00067 
00068 
00069 /*---------------------*
00070  *  class declaration  *
00071  *---------------------*/
00072 
00075 class DiImage
00076 {
00077 
00078  public:
00079 
00086     DiImage(const DiDocument *docu,
00087             const EI_Status status,
00088             const int spp);
00089 
00092     virtual ~DiImage();
00093 
00098     inline EI_Status getStatus() const
00099     {
00100         return ImageStatus;
00101     }
00102 
00107     inline Uint32 getNumberOfFrames() const
00108     {
00109         return NumberOfFrames;
00110     }
00111 
00116     inline Uint32 getFirstFrame() const
00117     {
00118         return FirstFrame;
00119     }
00120 
00125     inline Uint32 getRepresentativeFrame() const
00126     {
00127         return RepresentativeFrame;
00128     }
00129 
00134     inline Uint16 getRows() const
00135     {
00136         return Rows;
00137     }
00138 
00143     inline Uint16 getColumns() const
00144     {
00145          return Columns;
00146     }
00147 
00152     inline double getPixelWidth() const
00153     {
00154         return (PixelWidth > 0) ? PixelWidth : 1;
00155     }
00156 
00161     inline double getPixelHeight() const
00162     {
00163         return (PixelHeight > 0) ? PixelHeight : 1;
00164     }
00165 
00170     inline double getRowColumnRatio() const
00171     {
00172         return getPixelHeight() / getPixelWidth();
00173     }
00174 
00179     inline double getColumnRowRatio() const
00180     {
00181         return getPixelWidth() / getPixelHeight();
00182     }
00183 
00190     int setRowColumnRatio(const double ratio);
00191 
00198     int setColumnRowRatio(const double ratio);
00199 
00205     inline EP_Polarity getPolarity() const
00206     {
00207         return Polarity;
00208     }
00209 
00218     int setPolarity(const EP_Polarity polarity);
00219 
00224     virtual EP_Interpretation getInternalColorModel() const = 0;
00225 
00236     virtual int getBits(const int bits = 0) const
00237     {
00238         return ((bits < 1) || (bits > MAX_BITS)) ? BitsPerSample : bits;
00239     }
00240 
00247     virtual unsigned long getOutputDataSize(const int bits = 0) const = 0;
00248 
00258     virtual const void *getOutputData(const unsigned long frame,
00259                                       const int bits,
00260                                       const int planar) = 0;
00261 
00273     virtual int getOutputData(void *buffer,
00274                               const unsigned long size,
00275                               const unsigned long frame,
00276                               const int bits,
00277                               const int planar) = 0;
00278 
00286     virtual const void *getOutputPlane(const int plane) const = 0;
00287 
00290     virtual void deleteOutputData() = 0;
00291 
00298     virtual DiOverlay *getOverlayPtr(const unsigned int /*idx*/)
00299     {
00300         return NULL;
00301     }
00302 
00307     virtual DiMonoImage *getMonoImagePtr()
00308     {
00309         return NULL;
00310     }
00311 
00319     virtual DiImage *createImage(const unsigned long fstart,
00320                                  const unsigned long fcount) const = 0;
00321 
00340     virtual DiImage *createScale(const signed long left_pos,
00341                                  const signed long top_pos,
00342                                  const unsigned long clip_width,
00343                                  const unsigned long clip_height,
00344                                  const unsigned long scale_width,
00345                                  const unsigned long scale_height,
00346                                  const int interpolate,
00347                                  const int aspect,
00348                                  const Uint16 pvalue) const = 0;
00349 
00357     virtual int flip(const int horz,
00358                      const int vert) = 0;
00359 
00367     virtual DiImage *createFlip(const int horz,
00368                                 const int vert) const = 0;
00369 
00376     virtual int rotate(const int degree);
00377 
00384     virtual DiImage *createRotate(const int degree) const = 0;
00385 
00394     virtual DiImage *createMono(const double red,
00395                                 const double green,
00396                                 const double blue) const = 0;
00397 
00409     virtual unsigned long createDIB(void *&data,
00410                                     const unsigned long size,
00411                                     const unsigned long frame,
00412                                     const int bits,
00413                                     const int upsideDown,
00414                                     const int padding = 1) = 0;
00415 
00424     virtual unsigned long createAWTBitmap(void *&data,
00425                                           const unsigned long frame,
00426                                           const int bits) = 0;
00427 
00437     int writeFrameToDataset(DcmItem &dataset,
00438                             const unsigned long frame = 0,
00439                             const int bits = 0,
00440                             const int planar = 0);
00441 
00448     virtual int writeImageToDataset(DcmItem &dataset) = 0;
00449 
00459     virtual int writePPM(ostream &stream,
00460                          const unsigned long frame,
00461                          const int bits) = 0;
00462 
00472     virtual int writePPM(FILE *stream,
00473                          const unsigned long frame,
00474                          const int bits) = 0;
00475 
00484     virtual int writeRawPPM(FILE *stream,
00485                             const unsigned long frame,
00486                             const int bits) = 0;
00487 
00496     virtual int writeBMP(FILE *stream,
00497                          const unsigned long frame,
00498                          const int bits);
00499 
00500 
00501  protected:
00502 
00508     DiImage(const DiDocument *docu,
00509             const EI_Status status);
00510 
00517     DiImage(const DiImage *image,
00518             const unsigned long fstart,
00519             const unsigned long fcount);
00520 
00528     DiImage(const DiImage *image,
00529             const Uint16 width,
00530             const Uint16 height,
00531             const int aspect = 0);
00532 
00538     DiImage(const DiImage *image,
00539             const int degree = 0);
00540 
00548     DiImage(const DiImage *image,
00549             const unsigned long frame,
00550             const int stored,
00551             const int alloc);
00552 
00555     void deleteInputData();
00556 
00559     void checkPixelExtension();
00560 
00566     void convertPixelData(/*const*/ DcmPixelData *pixel,
00567                           const int spp);
00568 
00576     virtual void updateImagePixelModuleAttributes(DcmItem &dataset);
00577 
00581     int detachPixelData();
00582 
00584     EI_Status ImageStatus;
00586     const DiDocument *Document;
00587 
00589     Uint32 FirstFrame;
00591     Uint32 NumberOfFrames;
00593     Uint32 RepresentativeFrame;
00595     Uint16 Rows;
00597     Uint16 Columns;
00599     double PixelWidth;
00601     double PixelHeight;
00603     Uint16 BitsAllocated;
00605     Uint16 BitsStored;
00607     Uint16 HighBit;
00608 
00610     int BitsPerSample;
00611 
00613     EP_Polarity Polarity;
00614 
00616     int hasSignedRepresentation;
00618     int hasPixelSpacing;
00620     int hasImagerPixelSpacing;
00622     int hasPixelAspectRatio;
00624     int isOriginal;
00625 
00627     DiInputPixel *InputData;
00628 
00629  // --- declarations to avoid compiler warnings
00630 
00631     DiImage(const DiImage &);
00632     DiImage &operator=(const DiImage &);
00633 };
00634 
00635 
00636 #endif
00637 
00638 
00639 /*
00640  *
00641  * CVS/RCS Log:
00642  * $Log: diimage.h,v $
00643  * Revision 1.34  2004/02/06 11:07:50  joergr
00644  * Distinguish more clearly between const and non-const access to pixel data.
00645  *
00646  * Revision 1.33  2004/01/05 14:52:20  joergr
00647  * Removed acknowledgements with e-mail addresses from CVS log.
00648  *
00649  * Revision 1.32  2003/12/08 18:22:26  joergr
00650  * Removed leading underscore characters from preprocessor symbols (reserved
00651  * symbols). Updated CVS header.
00652  *
00653  * Revision 1.31  2003/06/12 15:08:34  joergr
00654  * Fixed inconsistent API documentation reported by Doxygen.
00655  *
00656  * Revision 1.30  2003/05/20 09:20:41  joergr
00657  * Added method returning the number of bytes required to store a single
00658  * rendered frame: getOutputDataSize().
00659  *
00660  * Revision 1.29  2002/12/09 13:32:51  joergr
00661  * Renamed parameter/local variable to avoid name clashes with global
00662  * declaration left and/or right (used for as iostream manipulators).
00663  *
00664  * Revision 1.28  2002/11/27 14:08:04  meichel
00665  * Adapted module dcmimgle to use of new header file ofstdinc.h
00666  *
00667  * Revision 1.27  2002/11/26 14:48:32  joergr
00668  * Added Smallest/LargestImagePixelValue to the list of attributes to be
00669  * removed from a newly created dataset.
00670  *
00671  * Revision 1.26  2002/08/02 15:03:20  joergr
00672  * Enhanced writeFrameToDataset() routine (remove out-data DICOM attributes
00673  * from the dataset).
00674  * Added function to write the current image (not only a selected frame) to a
00675  * DICOM dataset.
00676  *
00677  * Revision 1.25  2002/06/26 16:01:55  joergr
00678  * Added support for polarity flag to color images.
00679  * Added new method to write a selected frame to a DICOM dataset (incl. required
00680  * attributes from the "Image Pixel Module").
00681  *
00682  * Revision 1.24  2002/04/16 13:53:11  joergr
00683  * Added configurable support for C++ ANSI standard includes (e.g. streams).
00684  *
00685  * Revision 1.23  2002/01/29 17:05:50  joergr
00686  * Added optional flag to the "Windows DIB" methods allowing to switch off the
00687  * scanline padding.
00688  *
00689  * Revision 1.22  2001/11/27 18:18:22  joergr
00690  * Added support for plugable output formats in class DicomImage. First
00691  * implementation is JPEG.
00692  *
00693  * Revision 1.21  2001/11/09 16:26:37  joergr
00694  * Added support for Window BMP file format.
00695  * Enhanced and renamed createTrueColorDIB() method.
00696  *
00697  * Revision 1.20  2001/06/20 15:12:49  joergr
00698  * Enhanced multi-frame support for command line tool 'dcm2pnm': extract all
00699  * or a range of frames with one call.
00700  *
00701  * Revision 1.19  2001/06/01 15:49:42  meichel
00702  * Updated copyright header
00703  *
00704  * Revision 1.18  2000/03/08 16:24:16  meichel
00705  * Updated copyright header.
00706  *
00707  * Revision 1.17  2000/02/02 11:02:38  joergr
00708  * Removed space characters before preprocessor directives.
00709  *
00710  * Revision 1.16  1999/10/06 13:28:21  joergr
00711  * Corrected creation of PrintBitmap pixel data: VOI windows should be applied
00712  * before clipping to avoid that the region outside the image (border) is also
00713  * windowed (this requires a new method in dcmimgle to create a DicomImage
00714  * with the grayscale transformations already applied).
00715  *
00716  * Revision 1.15  1999/09/17 12:12:18  joergr
00717  * Added/changed/completed DOC++ style comments in the header files.
00718  *
00719  * Revision 1.14  1999/08/25 16:39:31  joergr
00720  * Allow clipping region to be outside the image (overlapping).
00721  *
00722  * Revision 1.13  1999/07/23 13:53:00  joergr
00723  * Added support for attribute 'ImagerPixelSpacing'.
00724  * Added support for attribute 'RepresentativeFrameNumber'.
00725  * Added methods to set 'PixelAspectRatio'.
00726  *
00727  * Revision 1.12  1999/04/28 14:47:34  joergr
00728  * Added experimental support to create grayscale images with more than 256
00729  * shades of gray to be displayed on a consumer monitor (use pastel colors).
00730  *
00731  * Revision 1.11  1999/03/24 17:20:01  joergr
00732  * Added/Modified comments and formatting.
00733  *
00734  * Revision 1.10  1999/02/08 12:38:12  joergr
00735  * Added parameter 'idx' to some overlay methods to distinguish between
00736  * built-in and additional overlay planes.
00737  *
00738  * Revision 1.9  1999/02/03 17:01:45  joergr
00739  * Added BEGIN_EXTERN_C and END_EXTERN_C to some C includes.
00740  *
00741  * Revision 1.8  1999/01/20 14:59:37  joergr
00742  * Added new output method to fill external memory buffer with rendered pixel
00743  * data.
00744  *
00745  * Revision 1.7  1999/01/11 09:32:32  joergr
00746  * Removed method 'getMinMaxValues()' in class 'DicomImage'.
00747  *
00748  * Revision 1.6  1998/12/23 11:33:08  joergr
00749  * Corrected some typos and formatting.
00750  *
00751  * Revision 1.5  1998/12/22 14:03:53  joergr
00752  * Changed parameter declaration to avoid compiler warnings (hide parameter
00753  * name).
00754  *
00755  * Revision 1.4  1998/12/16 16:29:04  joergr
00756  * Removed several methods used for monochrome images only in base class
00757  * 'DiImage'. Introduced mechanism to use the methods directly.
00758  *
00759  * Revision 1.3  1998/12/14 17:17:29  joergr
00760  * Added methods to add and remove additional overlay planes (still untested).
00761  *
00762  * Revision 1.2  1998/11/30 12:24:07  joergr
00763  * Added const type qualifier to some parameters to avoid errors with MSVC5
00764  * (couldn't create instance of abstract class).
00765  *
00766  * Revision 1.1  1998/11/27 15:06:08  joergr
00767  * Added copyright message.
00768  * Added methods and constructors for flipping and rotating, changed for
00769  * scaling and clipping.
00770  * Added method to directly create java AWT bitmaps.
00771  * Renamed variable 'Status' to 'ImageStatus' because of possible conflicts
00772  * with X windows systems.
00773  * Added method to detach pixel data if it is no longer needed.
00774  * Added methods to support presentation LUTs and shapes.
00775  *
00776  * Revision 1.6  1998/07/01 08:39:21  joergr
00777  * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional
00778  * options), e.g. add copy constructors.
00779  *
00780  * Revision 1.5  1998/05/11 14:53:16  joergr
00781  * Added CVS/RCS header to each file.
00782  *
00783  *
00784  */


Generated on 8 Dec 2004 for OFFIS DCMTK Version 3.5.3 by Doxygen 1.3.9.1