Main Page   Class Overview   Pixels   Images   Geometry   Quick Index  

HxRgbLogMag.h

00001 /*
00002  *  Copyright (c) 2001, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *  Author(s):
00006  *  Jan-Mark Geusebroek (mark@science.uva.nl)
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 
00022  /* norm2 already taken in HxImageRep::getRgbPixels2d */
00023 
00024 template<class ValT, class ValDoubleT>
00025 class HxRgbLogMag
00026 {
00027 public:
00028                         HxRgbLogMag(HxTagList& tags)
00029                     {
00030                         _lowVal = HxGetTag(tags, "lowVal", double(0));
00031                         _highVal = HxGetTag(tags, "highVal", double(255));
00032                         _lowVal -= 1.0;
00033                         _factor = 255.0/::log(_highVal-_lowVal);
00034                     }
00035 
00036     int                 doIt(const ValT& pixV)
00037                 {
00038                     double v = ::log(pixV.x()-_lowVal);
00039                     int x = (int) (v*_factor);
00040                     return (255 << 24) | (x << 16) | (x << 8) | x;
00041                 }
00042 
00043     int                 doItDouble(const ValDoubleT& pixV)
00044                 {
00045                     double v = ::log(pixV.x()-_lowVal);
00046                     int x = (int) (v*_factor);
00047                     return (255 << 24) | (x << 16) | (x << 8) | x;
00048                 }
00049 
00050     static HxString     className()
00051                             { return HxString("LogMagnitude"); }
00052 
00053 private:
00054     double              _lowVal;
00055     double              _highVal;
00056     double              _factor;
00057 };
00058 
00059 
00060 #endif

Generated on Tue Jan 8 13:59:16 2002 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001