dcmimage/include/dcmtk/dcmimage/diqtpix.h

00001 /*
00002  *
00003  *  Copyright (C) 2002-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:  Marco Eichelberg
00017  *
00018  *  Purpose: class DcmQuantPixel
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-14 13:16:30 $
00022  *  CVS/RCS Revision: $Revision: 1.4 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 
00030 #ifndef DIQTPIX_H
00031 #define DIQTPIX_H
00032 
00033 
00034 #include "dcmtk/config/osconfig.h"
00035 #include "dcmtk/ofstd/oftypes.h"   /* for OFBool */
00036 #include "dcmtk/dcmimage/diqttype.h"  /* for DcmQuantHashSize, DcmQuantComponent */
00037 #include "dcmtk/dcmimage/diqtstab.h"  /* for DcmScaleTable */
00038 
00039 
00044 class DcmQuantPixel
00045 {
00046 public:
00047 
00050   DcmQuantPixel()
00051   : red(0)
00052   , green(0)
00053   , blue(0)
00054   {
00055   }
00056 
00059   DcmQuantPixel(const DcmQuantPixel& arg)
00060   : red(arg.red)
00061   , green(arg.green)
00062   , blue(arg.blue)
00063   {
00064   }
00065 
00066   // we don't declare a destructor here, but the standard destructor will do.
00067 
00069   inline OFBool operator==(const DcmQuantPixel& src) const
00070   {
00071     return (red == src.red) && (green == src.green) && (blue == src.blue);
00072   }
00073 
00080   inline double luminance() const
00081   {
00082     return 0.299 * red + 0.587 * green + 0.114 * blue;
00083   }
00084 
00090   inline unsigned long hash() const
00091   {
00092     return ((OFstatic_cast(unsigned long, red) * 33023UL + OFstatic_cast(unsigned long, green) * 30013UL +
00093             OFstatic_cast(unsigned long, blue) * 27011UL) & 0x7fffffffUL) % DcmQuantHashSize;
00094   }
00095 
00099   inline DcmQuantComponent getRed() const
00100   {
00101     return red;
00102   }
00103 
00107   inline DcmQuantComponent getGreen() const
00108   {
00109     return green;
00110   }
00111 
00115   inline DcmQuantComponent getBlue() const
00116   {
00117     return blue;
00118   }
00119 
00125   inline void assign(
00126     DcmQuantComponent r,
00127     DcmQuantComponent g,
00128     DcmQuantComponent b)
00129   {
00130     red = r;
00131     green = g;
00132     blue = b;
00133   }
00134 
00143   inline void scale(
00144     DcmQuantComponent r,
00145     DcmQuantComponent g,
00146     DcmQuantComponent b,
00147     const DcmQuantScaleTable& table)
00148   {
00149     red   = table[r];
00150     green = table[g];
00151     blue  = table[b];
00152   }
00153 
00154 private:
00156   DcmQuantComponent red;
00157 
00159   DcmQuantComponent green;
00160 
00162   DcmQuantComponent blue;
00163 };
00164 
00165 
00166 #endif
00167 
00168 
00169 /*
00170  * CVS/RCS Log:
00171  * $Log: diqtpix.h,v $
00172  * Revision 1.4  2010-10-14 13:16:30  joergr
00173  * Updated copyright header. Added reference to COPYRIGHT file.
00174  *
00175  * Revision 1.3  2005/12/08 16:01:53  meichel
00176  * Changed include path schema for all DCMTK header files
00177  *
00178  * Revision 1.2  2003/12/23 12:20:07  joergr
00179  * Adapted type casts to new-style typecast operators defined in ofcast.h.
00180  * Updated copyright header.
00181  *
00182  * Revision 1.1  2002/01/25 13:32:07  meichel
00183  * Initial release of new color quantization classes and
00184  *   the dcmquant tool in module dcmimage.
00185  *
00186  *
00187  */


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