dicomot.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:  dcmimage
00019  *
00020  *  Author:  Joerg Riesmeier
00021  *
00022  *  Purpose: DicomColorMonochromeTemplate (Header)
00023  *
00024  *  Last Update:         $Author: meichel $
00025  *  Update Date:         $Date: 2005/12/08 16:01:31 $
00026  *  CVS/RCS Revision:    $Revision: 1.15 $
00027  *  Status:              $State: Exp $
00028  *
00029  *  CVS/RCS Log at end of file
00030  *
00031  */
00032 
00033 
00034 #ifndef DICOMOT_H
00035 #define DICOMOT_H
00036 
00037 #include "dcmtk/config/osconfig.h"
00038 
00039 #include "dcmtk/dcmimgle/dimopxt.h"
00040 #include "dcmtk/dcmimage/dicopx.h"
00041 
00042 
00043 /*---------------------*
00044  *  class declaration  *
00045  *---------------------*/
00046 
00050 template<class T>
00051 class DiColorMonoTemplate
00052   : public DiMonoPixelTemplate<T>
00053 {
00054 
00055  public:
00056 
00065     DiColorMonoTemplate(const DiColorPixel *pixel,
00066                         DiMonoModality *modality,
00067                         const double red,
00068                         const double green,
00069                         const double blue)
00070       : DiMonoPixelTemplate<T>(pixel, modality)
00071     {
00072         if ((pixel != NULL) && (pixel->getCount() > 0))
00073         {
00074             convert(OFstatic_cast(const T **, OFconst_cast(void *, pixel->getData())), red, green, blue);
00075             this->determineMinMax();
00076         }
00077     }
00078 
00081     virtual ~DiColorMonoTemplate()
00082     {
00083     }
00084 
00085 
00086  private:
00087 
00095     void convert(const T *pixel[3],
00096                  const double red,
00097                  const double green,
00098                  const double blue)
00099     {
00100         if (pixel != NULL)
00101         {
00102             this->Data = new T[this->Count];
00103             if (this->Data != NULL)
00104             {
00105                 register const T *r = pixel[0];
00106                 register const T *g = pixel[1];
00107                 register const T *b = pixel[2];
00108                 register T *q = this->Data;
00109                 register unsigned long i;
00110                 for (i = this->Count; i != 0; i--)
00111                 {
00112                     *(q++) = OFstatic_cast(T, OFstatic_cast(double, *(r++)) * red +
00113                                               OFstatic_cast(double, *(g++)) * green +
00114                                               OFstatic_cast(double, *(b++)) * blue);
00115                 }
00116             }
00117         }
00118     }
00119 };
00120 
00121 
00122 #endif
00123 
00124 
00125 /*
00126  *
00127  * CVS/RCS Log:
00128  * $Log: dicomot.h,v $
00129  * Revision 1.15  2005/12/08 16:01:31  meichel
00130  * Changed include path schema for all DCMTK header files
00131  *
00132  * Revision 1.14  2004/04/21 10:00:31  meichel
00133  * Minor modifications for compilation with gcc 3.4.0
00134  *
00135  * Revision 1.13  2004/02/06 11:18:18  joergr
00136  * Distinguish more clearly between const and non-const access to pixel data.
00137  *
00138  * Revision 1.12  2003/12/23 11:21:12  joergr
00139  * Adapted type casts to new-style typecast operators defined in ofcast.h.
00140  * Removed leading underscore characters from preprocessor symbols (reserved
00141  * symbols). Added missing API documentation. Updated copyright header.
00142  *
00143  * Revision 1.11  2001/11/09 16:41:34  joergr
00144  * Removed 'inline' specifier from certain methods.
00145  *
00146  * Revision 1.10  2001/06/01 15:49:28  meichel
00147  * Updated copyright header
00148  *
00149  * Revision 1.9  2000/03/08 16:21:50  meichel
00150  * Updated copyright header.
00151  *
00152  * Revision 1.8  1999/09/17 14:03:42  joergr
00153  * Enhanced efficiency of some "for" loops.
00154  *
00155  * Revision 1.7  1999/05/31 13:01:13  joergr
00156  * Corrected bug concerning the conversion of color images to grayscale.
00157  *
00158  * Revision 1.6  1999/04/28 12:51:58  joergr
00159  * Corrected some typos, comments and formatting.
00160  *
00161  * Revision 1.5  1999/01/20 14:40:41  joergr
00162  * Replaced invocation of getCount() by member variable Count where possible.
00163  *
00164  * Revision 1.4  1998/11/27 13:43:54  joergr
00165  * Added copyright message.
00166  *
00167  * Revision 1.3  1998/05/11 14:53:11  joergr
00168  * Added CVS/RCS header to each file.
00169  *
00170  *
00171  */


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