dcmimage/include/dcmtk/dcmimage/diqtstab.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 DcmQuantScaleTable
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-14 13:16:30 $
00022  *  CVS/RCS Revision: $Revision: 1.5 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 
00030 #ifndef DIQTSTAB_H
00031 #define DIQTSTAB_H
00032 
00033 
00034 #include "dcmtk/config/osconfig.h"
00035 #include "dcmtk/ofstd/ofcast.h"
00036 #include "dcmtk/dcmimage/diqttype.h"  /* for DcmQuantComponent */
00037 
00038 #define INCLUDE_CSTDLIB
00039 #define INCLUDE_CASSERT
00040 #include "dcmtk/ofstd/ofstdinc.h"
00041 
00042 
00048 class DcmQuantScaleTable
00049 {
00050 public:
00051 
00053   DcmQuantScaleTable()
00054   : table(NULL)
00055   , numEntries(0)
00056   {
00057   }
00058 
00060   ~DcmQuantScaleTable()
00061   {
00062     cleanup();
00063   }
00064 
00071   inline DcmQuantComponent operator[](unsigned int idx) const
00072   {
00073 #ifdef DEBUG
00074     assert(idx < numEntries);
00075 #endif
00076     return table[idx];
00077   }
00078 
00083   void createTable(
00084     unsigned long oldmaxval,
00085     unsigned long newmaxval)
00086   {
00087     cleanup();
00088 
00089     table = new DcmQuantComponent[oldmaxval+1];
00090     if (table)
00091     {
00092       numEntries = OFstatic_cast(unsigned int, oldmaxval) + 1;
00093       for (unsigned int i=0; i < numEntries; i++)
00094         table[i] = OFstatic_cast(DcmQuantComponent, (OFstatic_cast(unsigned long, i) * newmaxval + oldmaxval/2) / oldmaxval);
00095     }
00096   }
00097 
00098 private:
00099 
00101   inline void cleanup()
00102   {
00103     delete[] table;
00104     table = NULL;
00105     numEntries = 0;
00106   }
00107 
00109   DcmQuantScaleTable(const DcmQuantScaleTable& src);
00110 
00112   DcmQuantScaleTable& operator=(const DcmQuantScaleTable& src);
00113 
00115   DcmQuantComponent *table;
00116 
00118   unsigned int numEntries;
00119 };
00120 
00121 
00122 #endif
00123 
00124 
00125 /*
00126  * CVS/RCS Log:
00127  * $Log: diqtstab.h,v $
00128  * Revision 1.5  2010-10-14 13:16:30  joergr
00129  * Updated copyright header. Added reference to COPYRIGHT file.
00130  *
00131  * Revision 1.4  2005/12/08 16:01:54  meichel
00132  * Changed include path schema for all DCMTK header files
00133  *
00134  * Revision 1.3  2003/12/23 12:20:44  joergr
00135  * Adapted type casts to new-style typecast operators defined in ofcast.h.
00136  * Updated copyright header.
00137  *
00138  * Revision 1.2  2002/11/27 14:16:56  meichel
00139  * Adapted module dcmimage to use of new header file ofstdinc.h
00140  *
00141  * Revision 1.1  2002/01/25 13:32:07  meichel
00142  * Initial release of new color quantization classes and
00143  *   the dcmquant tool in module dcmimage.
00144  *
00145  *
00146  */


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