9 #include <boost/signals2.hpp>
10 #include <boost/bind.hpp>
24 bool CalcCoefficients (
const unsigned short* inData,
int inWidth,
25 int inHeight,
float* coefficients);
26 bool SetOptimizationParameters (
int numCoefficients,
int maxIterations,
27 float* initialGuesses,
int startLine,
28 int stopLine,
int offset);
29 bool ComputeDispersionArray ();
31 std::vector<float> GetCoefficients () {
return _coefficients; }
33 void GetCoefficients (
float* coefficients);
34 bool SetCoefficients (
const float *source,
int len);
35 void ProcessChunk (
int start,
int stop,
bool localPad,
const SGL* inData,
36 SGL*& intensity, SGL*& interimData);
38 virtual void InitGPUMethods (
int programIndex) { }
39 virtual void OnWidthHeightChanged (
int width,
int height) { }
40 virtual bool SetDispersionArrays (
float *dispersionPhi) {
return false; }
43 void FringeMethodHilbert(
const T* inData, T*& outData, T*& interimData)
45 int width = _scanProcessor->GetWidth();
48 int cSize = width / _numChunks;
49 bool isZeroPad = _scanProcessor->GetIsZeroPad();
52 boost::thread_group threadGroup;
53 for (c = 0; c < _numChunks - 1; c++)
56 threadGroup.create_thread(boost::bind(&Dispersion::ProcessChunk,
this, cStart,
57 cStart + cSize, isZeroPad, c, inData, outData, interimData));
59 int cStart = (_numChunks - 1)*cSize;
60 threadGroup.create_thread(boost::bind(&Dispersion::ProcessChunk,
this, cStart, width,
61 isZeroPad, c, inData, outData, interimData));
62 threadGroup.join_all();
70 static std::mutex _mutexCorrect;
72 virtual void InitStorage ();
73 virtual void ReleaseStorage () { }
76 void SumCorrectedPhase(T &corrPhase,
int i)
78 if (_coefficients.size() == 0)
83 for (
int order = 0; order < (int)_coefficients.size(); order++)
85 corrPhase += _coefficients[order] * ShiftedLegendrePolynomial<T>(order, i);
90 boost::signals2::connection _widthHeightConnection;
93 std::vector<float> _coefficients;
94 std::vector<float> _coefficientsBackup;
96 std::vector<SGL> _dispersionArrayReal;
97 std::vector<SGL> _dispersionArrayImag;
98 std::vector<SGL> _dispersionArrayPhi;
99 std::vector<SGL> _interimData;
100 std::vector<float> _initialGuesses;
103 bool _findingDispCoeff;
108 UINT _startLine, _stopLine;
113 void ReleaseDispersionArrays ();
114 int Compute (
const unsigned short *raw,
float *&interim,
float *&outData);
115 void WriteDebugMessages (
int numLines);
116 void BackupCoefficients ();
117 bool FindBestDispersion (
const unsigned short* inData,
int length,
int numLines,
118 int width,
int height,
float* coefficients);
119 void CheckCandidates (
float startingGuess,
float increment,
int ai,
120 std::vector<float>& coeffOfVariance,
121 const unsigned short* inData, SGL*& intensity,
122 int length,
int numLines,
int height,
123 std::vector<float>& sumOfVariance);
125 T ShiftedLegendrePolynomial(
int order,
int x)
127 int height = _scanProcessor->GetHeight();
129 T y = (2 * x - (height - 1)) / (T)(height - 1);
134 return pow(y, order + 2);
141 ans = (T)(0.5 * (3 * y * y - 1));
144 ans = (T)(0.5 * (5 * y * y * y - 3 * y));
147 ans = (T)(0.125 *(35 * y * y * y * y - 30 * y * y + 3));
150 ans = (T)(0.125 *(63 * y * y * y * y * y - 70 * y * y * y + 15 * y));
153 ans = (T)((1 / 16.0)*(231 * y * y * y * y * y * y - 315 * y * y * y * y + 105 * y * y - 5));
156 ans = (T)((1 / 16.0)*(429 * y * y * y * y * y * y * y - 693 * y * y * y * y * y + 315 *
157 y * y * y - 35 * y));
typedefs used across UtensilConverter
Interface of the ScanProcessor class.
Definition: Dispersion.h:18
Class that processes scans.
Definition: ScanProcessor.h:32