00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "sampling.h"
00026 #include "paramset.h"
00027
00028 class MitchellFilter : public Filter {
00029 public:
00030
00031 MitchellFilter(float b, float c, float xw, float yw)
00032 : Filter(xw, yw) { B = b; C = c; }
00033 float Evaluate(float x, float y) const;
00034 float Mitchell1D(float x) const {
00035 x = fabsf(2.f * x);
00036 if (x > 1.f)
00037 return ((-B - 6*C) * x*x*x + (6*B + 30*C) * x*x +
00038 (-12*B - 48*C) * x + (8*B + 24*C)) * (1.f/6.f);
00039 else
00040 return ((12 - 9*B - 6*C) * x*x*x +
00041 (-18 + 12*B + 6*C) * x*x +
00042 (6 - 2*B)) * (1.f/6.f);
00043 }
00044 private:
00045 float B, C;
00046 };
00047
00048 float MitchellFilter::Evaluate(float x, float y) const {
00049 return Mitchell1D(x * invXWidth) *
00050 Mitchell1D(y * invYWidth);
00051 }
00052 extern "C" DLLEXPORT Filter *CreateFilter(const ParamSet &ps) {
00053
00054 float xw = ps.FindOneFloat("xwidth", 2.);
00055 float yw = ps.FindOneFloat("ywidth", 2.);
00056 float B = ps.FindOneFloat("B", 1.f/3.f);
00057 float C = ps.FindOneFloat("C", 1.f/3.f);
00058 return new MitchellFilter(B, C, xw, yw);
00059 }