Openholo  beta 2.0
Open Source Digital Holographic Library
Get Parameter-AT

Functions

double ophSig::sigGetParamAT ()
 Extraction of distance parameter using axis transfomation . More...
 

Detailed Description

This module is related method which extraction of distance parameter using axis transformation method.

Introduction

Algorithm

Reference

Function Documentation

◆ sigGetParamAT()

double ophSig::sigGetParamAT ( )

Extraction of distance parameter using axis transfomation .

Returns
result distance

Definition at line 891 of file ophSig.cpp.

891  {
892 
893  int i = 0, j = 0;
894  Real max = 0; double index = 0;
895  float NA_g = (float)0.025;
896  int nx = context_.pixel_number[_X];
897  int ny = context_.pixel_number[_Y];
898 
899  OphComplexField Flr(nx, ny);
900  OphComplexField Fli(nx, ny);
901  OphComplexField Hsyn(nx, ny);
902  OphComplexField Hsyn_copy1(nx, ny);
903  OphComplexField Hsyn_copy2(nx, ny);
904  OphRealField Hsyn_copy3(nx, ny);
905 
906  OphComplexField Fo(nx, ny);
907  OphComplexField Fon, yn, Ab_yn;
908 
909  OphRealField Ab_yn_half;
910  OphRealField G(nx, ny);
911  Real r = 1, c = 1;
912  vector<Real> t, tn;
913 
914  for (i = 0; i < nx; i++)
915  {
916  for (j = 0; j < ny; j++)
917  {
918 
919  r = (2 * M_PI*(i) / _height - M_PI*(nx - 1) / _height);
920  c = (2 * M_PI*(j) / _width - M_PI*(ny - 1) / _width);
921  G(i, j) = std::exp(-M_PI * (context_.wave_length[0] / (2 * M_PI * NA_g)) * (context_.wave_length[0] / (2 * M_PI * NA_g)) * (c * c + r * r));
922  Flr(i, j)._Val[0] = ComplexH[0](i, j)._Val[0];
923  Fli(i, j)._Val[0] = ComplexH[0](i, j)._Val[1];
924  Flr(i, j)._Val[1] = 0;
925  Fli(i, j)._Val[1] = 0;
926  }
927  }
928 
929  fft2(Flr, Flr);
930  fft2(Fli, Fli);
931 
932  int xshift = nx / 2;
933  int yshift = ny / 2;
934 
935  for (i = 0; i < nx; i++)
936  {
937  int ii = (i + xshift) % nx;
938  for (j = 0; j < ny; j++)
939  {
940  Hsyn(i, j)._Val[_RE] = Flr(i, j)._Val[_RE] * G(i, j);
941  Hsyn(i, j)._Val[_IM] = Fli(i, j)._Val[_RE] * G(i, j);
942  Hsyn_copy1(i, j) = Hsyn(i, j);
943  Hsyn_copy2(i, j) = Hsyn_copy1(i, j) * Hsyn(i, j);
944  Hsyn_copy3(i, j) = pow(sqrt(Hsyn(i, j)._Val[_RE] * Hsyn(i, j)._Val[_RE] + Hsyn(i, j)._Val[_IM] * Hsyn(i, j)._Val[_IM]), 2) + pow(10, -300);
945  int jj = (j + yshift) % ny;
946  Fo(ii, jj)._Val[_RE] = Hsyn_copy2(i, j)._Val[0] / Hsyn_copy3(i, j);
947  Fo(ii, jj)._Val[_IM] = Hsyn_copy2(i, j)._Val[1] / Hsyn_copy3(i, j);
948  }
949  }
950 
951  t = linspace(0, 1, nx / 2 + 1);
952  tn.resize(t.size());
953  Fon.resize(1, t.size());
954 
955  for (int i = 0; i < tn.size(); i++)
956  {
957  tn.at(i) = pow(t.at(i), 0.5);
958  Fon(0, i)._Val[0] = Fo(nx / 2 - 1, nx / 2 - 1 + i)._Val[0];
959  Fon(0, i)._Val[1] = 0;
960  }
961 
962  yn.resize(1, static_cast<int>(tn.size()));
963  linInterp(t, Fon, tn, yn);
964  fft1(yn, yn);
965  Ab_yn.resize(yn.size[_X], yn.size[_Y]);
966  absMat(yn, Ab_yn);
967  Ab_yn_half.resize(1, nx / 4 + 1);
968 
969  for (int i = 0; i < nx / 4 + 1; i++)
970  {
971  Ab_yn_half(0, i) = Ab_yn(0, nx / 4 + i - 1)._Val[_RE];
972  if (i == 0) max = Ab_yn_half(0, 0);
973  else
974  {
975  if (Ab_yn_half(0, i) > max)
976  {
977  max = Ab_yn_half(0, i);
978  index = i;
979  }
980  }
981  }
982  index = -(((index + 1) - 120) / 10) / 140 + 0.1;
983 
984  return index;
985 }
void fft1(matrix< Complex< T >> &src, matrix< Complex< T >> &dst, int sign=OPH_FORWARD, uint flag=OPH_ESTIMATE)
Function for Fast Fourier transform 1D.
Definition: ophSig.cpp:190
void fft2(matrix< Complex< T >> &src, matrix< Complex< T >> &dst, int sign=OPH_FORWARD, uint flag=OPH_ESTIMATE)
Function for Fast Fourier transform 2D.
Definition: ophSig.cpp:226
vector< Real > linspace(double first, double last, int len)
Generate linearly spaced vector.
Definition: ophSig.cpp:272
void absMat(matrix< Complex< T >> &src, matrix< T > &dst)
Function for extracts Complex magnitude value.
Definition: ophSig.cpp:59
void linInterp(vector< T > &X, matrix< Complex< T >> &in, vector< T > &Xq, matrix< Complex< T >> &out)
Function for Linear interpolation 1D.
Definition: ophSig.cpp:295