00001
00049 #ifndef INC_MI32_CONTRASTPARM_H
00050 #define INC_MI32_CONTRASTPARM_H
00051
00052 #ifndef INC_MI32_SIMPLEAR_H
00053 #include <mi32/simplear.h>
00054 #endif
00055
00056 #ifndef INC_MI32_RANGE_H
00057 #include <mi32/range.h>
00058 #endif
00059
00060 #ifndef INC_MI32_NUMTYPE_H
00061 #include <mi32/numtype.h>
00062 #endif
00063
00064 #ifdef RVCSYSDLL
00065 #define LIBEXPORT MI_DLLEXPORT
00066 #define CLASSEXPORT MI_DLLCLASSEXPORT
00067 #else
00068 #define LIBEXPORT MI_DLLIMPORT
00069 #define CLASSEXPORT MI_DLLCLASSIMPORT
00070 #endif
00071
00072 #ifndef GENERATING_DOXYGEN_OUTPUT
00073 class STAT_UNIVARIATE;
00074 class SERIALIZERITEM;
00075 #endif
00076
00078
00079 class CLASSEXPORT CONTRASTPARM {
00080 public:
00081
00083
00084 enum METHOD {
00085 METHOD_None = 0,
00086 METHOD_Linear = 1,
00087 METHOD_Normalize = 2,
00088 METHOD_Equalize = 3,
00089 METHOD_Exponential = 4,
00090
00091
00092 METHOD_SavedTable = 7,
00093
00094 METHOD_Logarithmic = 9,
00095 METHOD_Constant = 10
00096 };
00097
00099 CONTRASTPARM ();
00100
00102 CONTRASTPARM (
00103 const CONTRASTPARM& rhs
00104 );
00105
00107 ~CONTRASTPARM ();
00108
00110 CONTRASTPARM& operator= (
00111 const CONTRASTPARM& rhs
00112 );
00113
00116 void AttachTable (
00117 UINT8 *& Table,
00118 UINT32 NumItems,
00119 double TableBinMinimum,
00120 double TableBinInterval
00121 );
00122
00124 bool CanComputeWithoutStats () const;
00125
00127 void Clear ();
00128
00130 void ClearTable ();
00131
00134 ERRVALUE ComputeTable (
00135 const STAT_UNIVARIATE& stats,
00136 const float *outspec = 0
00137 );
00138
00142 ERRVALUE ComputeTable ();
00143
00145 void DetachTable (
00146 SIMPLE_ARRAY<UINT8>& Table
00147 ) { Table.Swap(m_Table); m_Table.Clear(); }
00148
00150 const DOUBLE_RANGE& GetInputRangePct (
00151 ) const { return (m_InputRangePct); }
00152
00154 const DOUBLE_RANGE& GetInputStretchRange (
00155 ) const { return (m_InputRangeAbsolute); }
00156
00158 bool GetInvert (
00159 ) const { return (m_Invert); }
00160
00162 METHOD GetMethod (
00163 ) const { return (m_Method); }
00164
00166 double GetPower (
00167 ) const { return (m_Power); }
00168
00170 UINT8 GetOutputAboveMaxBin (
00171 ) const { return (m_OutAboveMaxBin); }
00172
00174 UINT8 GetOutputBelowMinBin (
00175 ) const { return (m_OutBelowMinBin); }
00176
00178 UINT8 GetOutputConstant (
00179 ) const { return (m_OutConstant); }
00180
00182 UINT8 GetOutputInvalid (
00183 ) const { return (m_OutInvalid); }
00184
00186 UINT8 GetOutputMedian (
00187 ) const { return (m_OutMedian); }
00188
00190 UINT8 GetOutputStdDevAboveMedian (
00191 ) const { return (m_OutStdDevAboveMedian); }
00192
00194 UINT8 GetOutputStdDevBelowMedian (
00195 ) const { return (m_OutStdDevBelowMedian); }
00196
00198 UINT8 GetOutputStretchMax (
00199 ) const { return (m_OutStretchMax); }
00200
00202 UINT8 GetOutputStretchMin (
00203 ) const { return (m_OutStretchMin); }
00204
00206 const SIMPLE_ARRAY<UINT8>& GetTable (
00207 ) const { return (m_Table); }
00208
00210 double GetTableBinInterval (
00211 ) const { return (m_TableBinInterval); }
00212
00214 const DOUBLE_RANGE& GetTableBinRange (
00215 ) const { return (m_TableBinRange); }
00216
00218 bool HasTable (
00219 ) const { return (!m_Table.IsEmpty()); }
00220
00222 bool IsInputRangePct (
00223 ) const { return (m_InputRangeUsePct); }
00224
00226 ERRVALUE Process (
00227 UINT32 count,
00228 const UINT8 *ibuffer,
00229 const UINT8 *validity,
00230 UINT8 *obuffer
00231 ) const;
00232
00234 ERRVALUE Process (
00235 UINT32 count,
00236 const INT8 *ibuffer,
00237 const UINT8 *validity,
00238 UINT8 *obuffer
00239 ) const;
00240
00242 ERRVALUE Process (
00243 UINT32 count,
00244 const UINT16 *ibuffer,
00245 const UINT8 *validity,
00246 UINT8 *obuffer
00247 ) const;
00248
00250 ERRVALUE Process (
00251 UINT32 count,
00252 const INT16 *ibuffer,
00253 const UINT8 *validity,
00254 UINT8 *obuffer
00255 ) const;
00256
00258 ERRVALUE Process (
00259 UINT32 count,
00260 const UINT32 *ibuffer,
00261 const UINT8 *validity,
00262 UINT8 *obuffer
00263 ) const;
00264
00266 ERRVALUE Process (
00267 UINT32 count,
00268 const INT32 *ibuffer,
00269 const UINT8 *validity,
00270 UINT8 *obuffer
00271 ) const;
00272
00274 ERRVALUE Process (
00275 UINT32 count,
00276 const float *ibuffer,
00277 const UINT8 *validity,
00278 UINT8 *obuffer
00279 ) const;
00280
00282 ERRVALUE Process (
00283 UINT32 count,
00284 const double *ibuffer,
00285 const UINT8 *validity,
00286 UINT8 *obuffer
00287 ) const;
00288
00290 ERRVALUE Process (
00291 UINT32 count,
00292 const void *ibuffer,
00293 const UINT8 *validity,
00294 UINT8 *obuffer,
00295 NUMTYPE NumType
00296 ) const;
00297
00299 void SetConstant (
00300 UINT8 OutConstant
00301 );
00302
00304 void SetExponential (
00305 double power
00306 );
00307
00310 void SetInputRangePct (
00311 double MinPct,
00312 double MaxPct
00313 );
00314
00316 void SetInputRangeUsePct (
00317 bool InputRangeUsePct
00318 ) { m_InputRangeUsePct = InputRangeUsePct; }
00319
00321 void SetInputStretchMax (
00322 double value
00323 ) { m_InputRangeAbsolute.SetMaximum(value); }
00324
00326 void SetInputStretchMin (
00327 double value
00328 ) { m_InputRangeAbsolute.SetMinimum(value); }
00329
00332 void SetInputStretchRange (
00333 const DOUBLE_RANGE InputRangeAbsolute
00334 ) { m_InputRangeUsePct = false; m_InputRangeAbsolute = InputRangeAbsolute; }
00335
00337 void SetInvert (
00338 bool Invert
00339 ) { m_Invert = Invert; }
00340
00342 void SetMethod (
00343 METHOD method,
00344 bool usedefaults = true
00345 );
00346
00348 void SetNormalize (
00349 UINT8 median,
00350 UINT8 StDevBelowMedian = 50,
00351 UINT8 StDevAboveMedian = 50
00352 );
00353
00355 void SetOutputAboveMaxBin (
00356 UINT8 OutAboveMaxBin
00357 ) { m_OutAboveMaxBin = OutAboveMaxBin; }
00358
00360 void SetOutputBelowMinBin (
00361 UINT8 OutBelowMinBin
00362 ) { m_OutBelowMinBin = OutBelowMinBin; }
00363
00365 void SetOutputInvalid (
00366 UINT8 OutInvalid
00367 ) { m_OutInvalid = OutInvalid; }
00368
00371 void SetOutputMedian (
00372 UINT8 median
00373 ) { m_OutMedian = median; }
00374
00377 void SetOutputStdDevAboveMedian (
00378 UINT8 StdDevAboveMedian
00379 ) { m_OutStdDevAboveMedian = StdDevAboveMedian; }
00380
00383 void SetOutputStdDevBelowMedian (
00384 UINT8 StdDevBelowMedian
00385 ) { m_OutStdDevBelowMedian = StdDevBelowMedian; }
00386
00388 void SetOutputStretchMax (
00389 UINT8 OutStretchMax
00390 ) { m_OutStretchMax = OutStretchMax; }
00391
00393 void SetOutputStretchMin (
00394 UINT8 OutStretchMin
00395 ) { m_OutStretchMin = OutStretchMin; }
00396
00398 ERRVALUE SetTable (
00399 const SIMPLE_ARRAY<UINT8>& Table,
00400 double TableBinMinimum,
00401 double TableBinInterval
00402 );
00403
00405 ERRVALUE SetTableBinRange (
00406 const DOUBLE_RANGE TableBinRange,
00407 double BinInterval
00408 );
00409
00411 static const SERIALIZERITEM* SerialGetItemDef ();
00412
00413 private:
00414 #ifndef GENERATING_DOXYGEN_OUTPUT
00415 typedef CONTRASTPARM THISCLASS;
00416 DOUBLE_RANGE m_InputRangePct;
00417 DOUBLE_RANGE m_InputRangeAbsolute;
00418 DOUBLE_RANGE m_TableBinRange;
00419 double m_TableBinInterval;
00420 double m_Power;
00421 METHOD m_Method;
00422 UINT8 m_OutStretchMin;
00423 UINT8 m_OutStretchMax;
00424 UINT8 m_OutMedian;
00425 UINT8 m_OutStdDevBelowMedian;
00426 UINT8 m_OutStdDevAboveMedian;
00427 UINT8 m_OutBelowMinBin;
00428 UINT8 m_OutAboveMaxBin;
00429 UINT8 m_OutInvalid;
00430 UINT8 m_OutConstant;
00431 bool m_Invert;
00432 bool m_UseDirectUINT8;
00433 bool m_InputRangeUsePct;
00434 SIMPLE_ARRAY<UINT8> m_Table;
00435
00436 ERRVALUE ComputeBinIdxRangeUsed (int& MinBinIdx, int& MaxBinIdx) const;
00437 void ComputeNormalSpec (float *spec) const;
00438 ERRVALUE ComputeTableNoStats (int NumBins = 0);
00439 void GetBinMinMaxInt (INT32& BinMinVal, INT32& BinMaxVal, INT32& BinInterval) const;
00440 void GetBinMinMaxInt (UINT32& BinMinVal, UINT32& BinMaxVal, UINT32& BinInterval) const;
00441 #endif // GENERATING_DOXYGEN_OUTPUT
00442 };
00443
00444
00445 #undef LIBEXPORT
00446 #undef CLASSEXPORT
00447
00448 #endif // INC_CONTRASTPARM_H
00449