00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef HxRgbLogMag_h
00011 #define HxRgbLogMag_h
00012
00013 #include "HxTagList.h"
00014 #include "HxClassName.h"
00015 #include "HxColConvert.h"
00016
00017 #include <cmath>
00018
00024 template<class ValT, class ValDoubleT>
00025 class HxRgbLogMag
00026 {
00027 public:
00029 typedef ValDoubleT ArithTypeDouble;
00030
00032 HxRgbLogMag(HxTagList& tags)
00033 {
00034 _lowVal = HxGetTag(tags, "lowVal", double(0));
00035 _highVal = HxGetTag(tags, "highVal", double(255));
00036 _lowVal -= 1.0;
00037 _factor = 255.0/::log(_highVal-_lowVal);
00038 }
00039
00041 int doIt(const ValT& pixV)
00042 {
00043 double v = ::log(pixV.x()-_lowVal);
00044 int x = (int) (v*_factor);
00045 return (255 << 24) | (x << 16) | (x << 8) | x;
00046 }
00047
00049 int doItDouble(const ValDoubleT& pixV)
00050 {
00051 double v = ::log(pixV.x()-_lowVal);
00052 int x = (int) (v*_factor);
00053 return (255 << 24) | (x << 16) | (x << 8) | x;
00054 }
00055
00057 static HxString className()
00058 { return HxString("LogMagnitude"); }
00059
00060 private:
00061 double _lowVal;
00062 double _highVal;
00063 double _factor;
00064 };
00065
00066
00067 #endif