2a87445078
removed old files define AEGISUB Originally committed to SVN as r204.
86 lines
1.6 KiB
C++
86 lines
1.6 KiB
C++
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle)
|
|
// All rights reserved but the aegisub project is allowed to use it.
|
|
|
|
#include <math.h>
|
|
#include "FexGenericFilter_Include.h"
|
|
|
|
FexFilter::FexFilter()
|
|
{
|
|
Width = 3;
|
|
}
|
|
FexFilter::~FexFilter()
|
|
{
|
|
}
|
|
double FexFilter::Filter( double t )
|
|
{
|
|
return t/Width;
|
|
}
|
|
|
|
|
|
/*
|
|
f(x) = e^(-x^2 / (2 s^2) )
|
|
f(x) = e^(-x^2 / t)
|
|
|
|
width:
|
|
SOLVE(0.1 = f(x), x, Real)
|
|
x = - sqrt(t LN(10) ? x = sqrt(t LN(10)
|
|
x = - 1.517427129·sqrt t ? x = 1.517427129·sqrt t
|
|
x = - sqrt(2*s*s* LN(10)) ? x = sqrt(2*s*s* LN(10))
|
|
x = - 2.145966026·s ? x = 2.145966026·s
|
|
|
|
sum:
|
|
|
|
Integral from -sqrt(t LN(10) to sqrt(t LN(10) of f(x) dx
|
|
1.715955662·sqrt(t)
|
|
2.426727768·s
|
|
*/
|
|
|
|
FexFilter_Gauss::FexFilter_Gauss( double sigma )
|
|
{
|
|
Sigma = sigma;
|
|
TwoSigmaSq = 2*sigma*sigma;
|
|
Width = 2.145966026 * sigma;
|
|
Normalize = 1.0 / (2.426727768 * sigma);
|
|
Normalize *= 1.0 + 0.1 / Width; //its the 0.1 we left out
|
|
}
|
|
FexFilter_Gauss::~FexFilter_Gauss()
|
|
{
|
|
}
|
|
|
|
double FexFilter_Gauss::Filter( double t )
|
|
{
|
|
return exp( -t*t / TwoSigmaSq ) * Normalize;
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
f(x) = -x * e^(-x^2 / (2 s^2) )
|
|
f(x) = -x * e^(-x^2 / t)
|
|
|
|
width:
|
|
use the width of gauss since i'm clueless here
|
|
|
|
sum:
|
|
|
|
Integral from -sqrt(t LN(10) to sqrt(t LN(10) of -x*f(x) dx
|
|
0.7062351183·t^1.5
|
|
*/
|
|
|
|
FexFilter_GaussDerivation::FexFilter_GaussDerivation( double sigma )
|
|
{
|
|
Sigma = sigma;
|
|
TwoSigmaSq = 2*sigma*sigma;
|
|
Width = 2.145966026 * sigma;
|
|
Normalize = 1.0 / (0.7062351183 * pow( TwoSigmaSq, 1.5 ));
|
|
}
|
|
|
|
FexFilter_GaussDerivation::~FexFilter_GaussDerivation()
|
|
{
|
|
}
|
|
|
|
double FexFilter_GaussDerivation::Filter( double t )
|
|
{
|
|
return -t * exp( -t*t / TwoSigmaSq ) * Normalize;
|
|
}
|