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: dcmimgle 00015 * 00016 * Author: Joerg Riesmeier 00017 * 00018 * Purpose: DicomMonochromeScaleTemplate (Header) 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:16:26 $ 00022 * CVS/RCS Revision: $Revision: 1.20 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 00030 #ifndef DIMOSCT_H 00031 #define DIMOSCT_H 00032 00033 #include "dcmtk/config/osconfig.h" 00034 #include "dcmtk/ofstd/ofcast.h" 00035 00036 #include "dcmtk/dcmimgle/dimopxt.h" 00037 #include "dcmtk/dcmimgle/discalet.h" 00038 #include "dcmtk/dcmimgle/didispfn.h" 00039 00040 00041 /*---------------------* 00042 * class declaration * 00043 *---------------------*/ 00044 00047 template<class T> 00048 class DiMonoScaleTemplate 00049 : public DiMonoPixelTemplate<T>, 00050 protected DiScaleTemplate<T> 00051 { 00052 00053 public: 00054 00071 DiMonoScaleTemplate(const DiMonoPixel *pixel, 00072 const Uint16 columns, 00073 const Uint16 rows, 00074 const signed long left_pos, 00075 const signed long top_pos, 00076 const Uint16 src_cols, 00077 const Uint16 src_rows, 00078 const Uint16 dest_cols, 00079 const Uint16 dest_rows, 00080 const Uint32 frames, 00081 const int bits, 00082 const int interpolate, 00083 const Uint16 pvalue) 00084 : DiMonoPixelTemplate<T>(pixel, OFstatic_cast(unsigned long, dest_cols) * OFstatic_cast(unsigned long, dest_rows) * frames), 00085 DiScaleTemplate<T>(1, columns, rows, left_pos, top_pos, src_cols, src_rows, dest_cols, dest_rows, frames, bits) 00086 { 00087 if ((pixel != NULL) && (pixel->getCount() > 0)) 00088 { 00089 if (pixel->getCount() == OFstatic_cast(unsigned long, columns) * OFstatic_cast(unsigned long, rows) * frames) 00090 { 00091 scale(OFstatic_cast(const T *, pixel->getData()), pixel->getBits(), interpolate, pvalue); 00092 this->determineMinMax(); 00093 } else { 00094 DCMIMGLE_WARN("could not scale image ... corrupted data"); 00095 } 00096 } 00097 } 00098 00101 virtual ~DiMonoScaleTemplate() 00102 { 00103 } 00104 00105 00106 private: 00107 00115 inline void scale(const T *pixel, 00116 const unsigned int bits, 00117 const int interpolate, 00118 const Uint16 pvalue) 00119 { 00120 if (pixel != NULL) 00121 { 00122 this->Data = new T[this->getCount()]; 00123 if (this->Data != NULL) 00124 { 00125 const T value = OFstatic_cast(T, OFstatic_cast(double, DicomImageClass::maxval(bits)) * 00126 OFstatic_cast(double, pvalue) / OFstatic_cast(double, DicomImageClass::maxval(WIDTH_OF_PVALUES))); 00127 scaleData(&pixel, &this->Data, interpolate, value); 00128 } 00129 } 00130 } 00131 }; 00132 00133 00134 #endif 00135 00136 00137 /* 00138 * 00139 * CVS/RCS Log: 00140 * $Log: dimosct.h,v $ 00141 * Revision 1.20 2010-10-14 13:16:26 joergr 00142 * Updated copyright header. Added reference to COPYRIGHT file. 00143 * 00144 * Revision 1.19 2010-03-01 09:08:47 uli 00145 * Removed some unnecessary include directives in the headers. 00146 * 00147 * Revision 1.18 2009-10-28 14:38:17 joergr 00148 * Fixed minor issues in log output. 00149 * 00150 * Revision 1.17 2009-10-28 09:53:40 uli 00151 * Switched to logging mechanism provided by the "new" oflog module. 00152 * 00153 * Revision 1.16 2008-05-20 13:12:48 joergr 00154 * Fixed issue with signed pixel data in bicubic interpolation algorithm. 00155 * 00156 * Revision 1.15 2006/08/15 16:30:11 meichel 00157 * Updated the code in module dcmimgle to correctly compile when 00158 * all standard C++ classes remain in namespace std. 00159 * 00160 * Revision 1.14 2005/12/08 16:47:58 meichel 00161 * Changed include path schema for all DCMTK header files 00162 * 00163 * Revision 1.13 2004/04/21 10:00:36 meichel 00164 * Minor modifications for compilation with gcc 3.4.0 00165 * 00166 * Revision 1.12 2003/12/09 10:04:45 joergr 00167 * Adapted type casts to new-style typecast operators defined in ofcast.h. 00168 * Removed leading underscore characters from preprocessor symbols (reserved 00169 * symbols). Updated copyright header. 00170 * 00171 * Revision 1.11 2002/12/09 13:32:54 joergr 00172 * Renamed parameter/local variable to avoid name clashes with global 00173 * declaration left and/or right (used for as iostream manipulators). 00174 * 00175 * Revision 1.10 2001/06/01 15:49:48 meichel 00176 * Updated copyright header 00177 * 00178 * Revision 1.9 2000/09/12 10:04:45 joergr 00179 * Corrected bug: wrong parameter for attribute search routine led to crashes 00180 * when multiple pixel data attributes were contained in the dataset (e.g. 00181 * IconImageSequence). Added new checking routines to avoid crashes when 00182 * processing corrupted image data. 00183 * 00184 * Revision 1.8 2000/03/08 16:24:21 meichel 00185 * Updated copyright header. 00186 * 00187 * Revision 1.7 1999/09/17 12:43:24 joergr 00188 * Added/changed/completed DOC++ style comments in the header files. 00189 * 00190 * Revision 1.6 1999/09/07 09:49:39 joergr 00191 * Removed register variable declaration to avoid compiler warnings. 00192 * 00193 * Revision 1.5 1999/08/25 16:41:54 joergr 00194 * Added new feature: Allow clipping region to be outside the image 00195 * (overlapping). 00196 * 00197 * Revision 1.4 1999/03/24 17:20:18 joergr 00198 * Added/Modified comments and formatting. 00199 * 00200 * Revision 1.3 1999/02/11 16:41:10 joergr 00201 * Corrected some typos and formatting. 00202 * 00203 * Revision 1.2 1998/12/16 16:36:11 joergr 00204 * *** empty log message *** 00205 * 00206 * Revision 1.1 1998/11/27 15:39:32 joergr 00207 * Added copyright message. 00208 * Combined clipping and scaling methods. 00209 * 00210 * Revision 1.4 1998/05/11 14:53:24 joergr 00211 * Added CVS/RCS header to each file. 00212 * 00213 * 00214 */