Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

plcontribdefs.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plcontribdefs.h,v 1.3 2002/11/04 22:40:13 uzadow Exp $
00005 |
00006 |      Copyright (c) 1996-2002 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #ifndef INCL_CONTRIBDEFS
00012 #define INCL_CONTRIBDEFS
00013 
00014 #include <math.h>
00015 
00016 class PLContribDef
00017 {
00018 public:
00019 
00020     PLContribDef (double dWidth) : m_dWidth (dWidth) {}
00021     virtual ~PLContribDef() {}
00022 
00023     double GetWidth() const             { return m_dWidth; }
00024     void   SetWidth (double dWidth)     { m_dWidth = dWidth; }
00025 
00026     virtual double Filter (double dVal) const = 0;
00027 
00028 protected:
00029 
00030     #define FILTER_PI  double (3.1415926535897932384626433832795)
00031     #define FILTER_2PI double (2.0 * 3.1415926535897932384626433832795)
00032     #define FILTER_4PI double (4.0 * 3.1415926535897932384626433832795)
00033 
00034     double  m_dWidth;
00035 };
00036 
00037 class PLBoxContribDef : public PLContribDef
00038 {
00039 public:
00040 
00041     PLBoxContribDef (double dWidth = 0.5) : PLContribDef(dWidth) {}
00042     virtual ~PLBoxContribDef() {}
00043 
00044     virtual double Filter (double dVal) const { return (fabs(dVal) <= m_dWidth ? 1.0 : 0.0); }
00045 };
00046 
00047 class PLBilinearContribDef : public PLContribDef
00048 {
00049 public:
00050 
00051     PLBilinearContribDef (double dWidth = 1.0) : PLContribDef(dWidth) {}
00052     virtual ~PLBilinearContribDef() {}
00053 
00054     virtual double Filter (double dVal) const
00055     {
00056         dVal = fabs(dVal);
00057         return (dVal < m_dWidth ? m_dWidth - dVal : 0.0);
00058     }
00059 };
00060 
00061 class PLGaussianContribDef : public PLContribDef
00062 {
00063 public:
00064 
00065     PLGaussianContribDef (double dWidth = 3.0) : PLContribDef(dWidth) {}
00066     virtual ~PLGaussianContribDef() {}
00067 
00068     virtual double Filter (double dVal) const
00069         {
00070             if (fabs (dVal) > m_dWidth)
00071             {
00072                 return 0.0;
00073             }
00074             return exp (-dVal * dVal / m_dWidth-1) / sqrt (FILTER_2PI);
00075         }
00076 };
00077 
00078 class PLHammingContribDef : public PLContribDef
00079 {
00080 public:
00081 
00082     PLHammingContribDef (double dWidth = 0.5) : PLContribDef(dWidth) {}
00083     virtual ~PLHammingContribDef() {}
00084 
00085     virtual double Filter (double dVal) const
00086         {
00087             if (fabs (dVal) > m_dWidth)
00088             {
00089                 return 0.0;
00090             }
00091             double dWindow = 0.54 + 0.46 * cos (FILTER_2PI * dVal);
00092             double dSinc = (dVal == 0) ? 1.0 : sin (FILTER_PI * dVal) / (FILTER_PI * dVal);
00093             return dWindow * dSinc;
00094         }
00095 };
00096 
00097 class PLBlackmanContribDef : public PLContribDef
00098 {
00099 public:
00100 
00101     PLBlackmanContribDef (double dWidth = 0.5) : PLContribDef(dWidth) {}
00102     virtual ~PLBlackmanContribDef() {}
00103 
00104     virtual double Filter (double dVal) const
00105         {
00106             if (fabs (dVal) > m_dWidth)
00107             {
00108                 return 0.0;
00109             }
00110             double dN = 2.0 * m_dWidth + 1.0;
00111             return 0.42 + 0.5 * cos (FILTER_2PI * dVal / ( dN - 1.0 )) +
00112                    0.08 * cos (FILTER_4PI * dVal / ( dN - 1.0 ));
00113         }
00114 };
00115 
00116 
00117 #endif  // _FILTERS_H_
00118 
00119 /*
00120 /--------------------------------------------------------------------
00121 |
00122 |      $Log: plcontribdefs.h,v $
00123 |      Revision 1.3  2002/11/04 22:40:13  uzadow
00124 |      Updated for gcc 3.1
00125 |
00126 |      Revision 1.2  2002/03/31 13:36:42  uzadow
00127 |      Updated copyright.
00128 |
00129 |      Revision 1.1  2001/09/30 16:58:23  uzadow
00130 |      Improved speed of 2passfilter.h, code readability changes.
00131 |
00132 |      Revision 1.1  2001/09/16 19:03:23  uzadow
00133 |      Added global name prefix PL, changed most filenames.
00134 |
00135 |      Revision 1.2  1999/12/02 17:07:34  Ulrich von Zadow
00136 |      Changes by bdelmee.
00137 |
00138 |      Revision 1.1  1999/10/21 16:05:17  Ulrich von Zadow
00139 |      Moved filters to separate directory. Added Crop, Grayscale and
00140 |      GetAlpha filters.
00141 |
00142 |      Revision 1.1  1999/10/19 21:29:55  Ulrich von Zadow
00143 |      Added filters.
00144 |
00145 |
00146 \--------------------------------------------------------------------
00147 */

Generated on Sun Jun 6 13:42:22 2004 for paintlib by doxygen 1.3.2