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