00001
00002
00004
00005
00006
00007
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef APSF_H
00023 #define APSF_H
00024
00025 #include <cmath>
00026 #include <gl/glut.h>
00027 #include <vector>
00028 #include "ppm\ppm.hpp"
00029
00030 using namespace std;
00031
00032 #ifndef M_PI
00033 #define M_PI 3.1415926535897931f
00034 #endif
00035
00039 class APSF
00040 {
00041 public:
00043 APSF(int res = 512);
00045 virtual ~APSF();
00046
00048 void read(const char* filename);
00050 void write(const char* filename);
00052 void writePPM(const char* filename);
00053
00055 void generateKernelFast();
00056
00058 int res() { return _res; };
00059
00061 float* kernel() { return _kernel; };
00062
00063 private:
00065 int _res;
00067 float* _kernel;
00068
00070
00072
00073
00074 float _q;
00075 float _T;
00076 float _I0;
00077 float _sigma;
00078 float _R;
00079 float _D;
00080
00081 float _retinaSize;
00082 float _eyeSize;
00083
00085 int _maxTerms;
00086
00088 float pointAPSF(float mu);
00089
00091
00093 float legendreM(int m, float mu);
00094 float gM(float I0, int m) {
00095 return (m == 0) ? 0.0f : exp(-(betaM(m, _q) * _T + alphaM(m) * log(_T)));
00096 };
00097 float alphaM(float m) {
00098 return m + 1.0f;
00099 };
00100 float betaM(float m, float q) {
00101 return ((2.0f * m + 1.0f) / m) * (1.0f - pow(q, (int)m - 1));
00102 };
00103 float factorial(float x) {
00104 return (x <= 1.0f) ? 1.0f : x * factorial(x - 1.0f);
00105 };
00106 float choose(float x, float y) {
00107 return factorial(x) / (factorial(y) * factorial(x - y));
00108 };
00109 };
00110
00111 #endif