00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
#ifndef DIMOSCT_H
00035
#define DIMOSCT_H
00036
00037
#include "osconfig.h"
00038
#include "dctypes.h"
00039
#include "ofcast.h"
00040
00041
#include "dimopxt.h"
00042
#include "discalet.h"
00043
00044
00045
00046
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
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198