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