dcmimage/include/dcmtk/dcmimage/dicomot.h

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


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1