HologramDepthmap Library
HologramGenerator_CPU.cpp
Go to the documentation of this file.
1 
3 #include "graphics/sys.h"
4 
5 fftw_plan fft_plan_fwd_;
6 fftw_plan fft_plan_bwd_;
7 
14 {
15  if (img_src_) free(img_src_);
16  img_src_ = (double*)malloc(sizeof(double)*params_.pn[0]*params_.pn[1]);
17 
18  if (dmap_src_) free(dmap_src_);
19  dmap_src_ = (double*)malloc(sizeof(double)*params_.pn[0]*params_.pn[1]);
20 
21  if (alpha_map_) free(alpha_map_);
22  alpha_map_ = (int*)malloc(sizeof(int) * params_.pn[0] * params_.pn[1] );
23 
24  if (depth_index_) free(depth_index_);
25  depth_index_ = (double*)malloc(sizeof(double) * params_.pn[0] * params_.pn[1]);
26 
27  if (dmap_) free(dmap_);
28  dmap_ = (double*)malloc(sizeof(double)* params_.pn[0] * params_.pn[1]);
29 
30  if (U_complex_) free(U_complex_);
31  U_complex_ = (Complex*)malloc(sizeof(Complex) * params_.pn[0] * params_.pn[1] );
32 
33  fftw_cleanup();
34 }
35 
44 bool HologramGenerator::prepare_inputdata_CPU(uchar* imgptr, uchar* dimgptr)
45 {
46  int pnx = params_.pn[0];
47  int pny = params_.pn[1];
48 
49  memset(img_src_, 0, sizeof(double)*pnx * pny);
50  memset(dmap_src_, 0, sizeof(double)*pnx * pny);
51  memset(alpha_map_, 0, sizeof(int)*pnx * pny);
52  memset(depth_index_, 0, sizeof(double)*pnx * pny);
53  memset(dmap_, 0, sizeof(double)*pnx * pny);
54 
55  int k = 0;
56 #pragma omp parallel for private(k)
57  for (k = 0; k < pnx*pny; k++)
58  {
59  img_src_[k] = double(imgptr[k]) / 255.0;
60  dmap_src_[k] = double(dimgptr[k]) / 255.0;
61  alpha_map_[k] = (imgptr[k] > 0 ? 1 : 0);
63 
65  depth_index_[k] = DEFAULT_DEPTH_QUANTIZATION - double(dimgptr[k]);
66  }
67 }
68 
75 {
76  int pnx = params_.pn[0];
77  int pny = params_.pn[1];
78 
79  double temp_depth, d1, d2;
80  int tdepth;
81 
82  for (int dtr = 0; dtr < params_.num_of_depth; dtr++)
83  {
84  temp_depth = dlevel_[dtr];
85  d1 = temp_depth - dstep_ / 2.0;
86  d2 = temp_depth + dstep_ / 2.0;
87 
88  int p;
89 #pragma omp parallel for private(p)
90  for (p = 0; p < pnx * pny; p++)
91  {
92  int tdepth;
93  if (dtr < params_.num_of_depth - 1)
94  tdepth = (dmap_[p] >= d1 ? 1 : 0) * (dmap_[p] < d2 ? 1 : 0);
95  else
96  tdepth = (dmap_[p] >= d1 ? 1 : 0) * (dmap_[p] <= d2 ? 1 : 0);
97 
98  depth_index_[p] += tdepth*(dtr + 1);
99  }
100  }
101 
102  //writeIntensity_gray8_bmp("test.bmp", pnx, pny, depth_index_);
103 }
104 
118 {
119  int pnx = params_.pn[0];
120  int pny = params_.pn[1];
121 
122  memset(U_complex_, 0.0, sizeof(Complex)*pnx*pny);
123  int depth_sz = params_.render_depth.size();
124 
125  fftw_complex *in, *out;
126  fft_plan_fwd_ = fftw_plan_dft_2d(pny, pnx, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
127 
128  int p = 0;
129 #pragma omp parallel for private(p)
130  for (p = 0; p < depth_sz; ++p)
131  {
132  int dtr = params_.render_depth[p];
133  double temp_depth = dlevel_transform_[dtr - 1];
134 
135  Complex* u_o = (Complex*)malloc(sizeof(Complex)*pnx*pny);
136  memset(u_o, 0.0, sizeof(Complex)*pnx*pny);
137 
138  double sum = 0.0;
139  for (int i = 0; i < pnx * pny; i++)
140  {
141  u_o[i].a = img_src_[i] * alpha_map_[i] * (depth_index_[i] == dtr ? 1.0 : 0.0);
142  sum += u_o[i].a;
143  }
144 
145  if (sum > 0.0)
146  {
147  LOG("Frame#: %d, Depth: %d of %d, z = %f mm\n", frame, dtr, params_.num_of_depth, -temp_depth * 1000);
148 
149  Complex rand_phase_val;
150  get_rand_phase_value(rand_phase_val);
151 
152  Complex carrier_phase_delay(0, params_.k* temp_depth);
153  exponent_complex(&carrier_phase_delay);
154 
155  for (int i = 0; i < pnx * pny; i++)
156  u_o[i] = u_o[i] * rand_phase_val * carrier_phase_delay;
157 
158  if (Propagation_Method_ == 0) {
159  fftwShift(u_o, u_o, in, out, pnx, pny, 1, false);
160  Propagation_AngularSpectrum_CPU(u_o, -temp_depth);
161  }
162 
163 
164 
165  }
166  else
167  LOG("Frame#: %d, Depth: %d of %d : Nothing here\n", frame, dtr, params_.num_of_depth);
168 
169  free(u_o);
170  }
171 
172  fftw_destroy_plan(fft_plan_fwd_);
173  fftw_cleanup();
174 
175  //writeIntensity_gray8_real_bmp("final_fr", pnx, pny, U_complex_);
176 
177 }
178 
186 void HologramGenerator::Propagation_AngularSpectrum_CPU(Complex* input_u, double propagation_dist)
187 {
188  int pnx = params_.pn[0];
189  int pny = params_.pn[1];
190  double ppx = params_.pp[0];
191  double ppy = params_.pp[1];
192  double ssx = params_.ss[0];
193  double ssy = params_.ss[1];
194  double lambda = params_.lambda;
195 
196  for (int i = 0; i < pnx * pny; i++)
197  {
198  double x = i % pnx;
199  double y = i / pnx;
200 
201  double fxx = (-1.0 / (2.0*ppx)) + (1.0 / ssx) * x;
202  double fyy = (1.0 / (2.0*ppy)) - (1.0 / ssy) - (1.0 / ssy) * y;
203 
204  double sval = sqrt(1 - (lambda*fxx)*(lambda*fxx) - (lambda*fyy)*(lambda*fyy));
205  sval *= params_.k * propagation_dist;
206  Complex kernel(0, sval);
207  exponent_complex(&kernel);
208 
209  int prop_mask = ((fxx * fxx + fyy * fyy) < (params_.k *params_.k)) ? 1 : 0;
210 
211  Complex u_frequency;
212  if (prop_mask == 1)
213  u_frequency = kernel * input_u[i];
214 
215  U_complex_[i] = U_complex_[i] + u_frequency;
216  }
217 
218 }
219 
231 void HologramGenerator::encoding_CPU(int cropx1, int cropx2, int cropy1, int cropy2, ivec2 sig_location)
232 {
233  int pnx = params_.pn[0];
234  int pny = params_.pn[1];
235 
236  Complex* h_crop = (Complex*)malloc(sizeof(Complex) * pnx*pny );
237  memset(h_crop, 0.0, sizeof(Complex)*pnx*pny);
238 
239  int p = 0;
240 #pragma omp parallel for private(p)
241  for (p = 0; p < pnx*pny; p++)
242  {
243  int x = p % pnx;
244  int y = p / pnx;
245  if (x >= cropx1 && x <= cropx2 && y >= cropy1 && y <= cropy2)
246  h_crop[p] = U_complex_[p];
247  }
248 
249  fftw_complex *in, *out;
250  fft_plan_bwd_ = fftw_plan_dft_2d(pny, pnx, in, out, FFTW_BACKWARD, FFTW_ESTIMATE);
251  fftwShift(h_crop, h_crop, in, out, pnx, pny, -1, true);
252  fftw_destroy_plan(fft_plan_bwd_);
253  fftw_cleanup();
254 
255  memset(u255_fringe_, 0.0, sizeof(double)*pnx*pny);
256  int i = 0;
257 #pragma omp parallel for private(i)
258  for (i = 0; i < pnx*pny; i++) {
259 
260  Complex shift_phase(1, 0);
261  get_shift_phase_value(shift_phase, i, sig_location);
262 
263  u255_fringe_[i] = (h_crop[i] * shift_phase).a;
264  }
265 
266  //writeIntensity_gray8_bmp("fringe_255", pnx, pny, u255_fringe_);
267 
268  free(h_crop);
269 
270 }
271 
285 void HologramGenerator::fftwShift(Complex* src, Complex* dst, fftw_complex* in, fftw_complex* out, int nx, int ny, int type, bool bNomarlized)
286 {
287  Complex* tmp = (Complex*)malloc(sizeof(Complex)*nx*ny);
288  memset(tmp, 0.0, sizeof(Complex)*nx*ny);
289  fftShift(nx, ny, src, tmp);
290 
291  in = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * nx * ny);
292  out = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * nx * ny);
293 
294  for (int i = 0; i < nx*ny; i++)
295  {
296  in[i][0] = tmp[i].a;
297  in[i][1] = tmp[i].b;
298  }
299 
300  if (type == 1)
301  fftw_execute_dft(fft_plan_fwd_, in, out);
302  else
303  fftw_execute_dft(fft_plan_bwd_, in, out);
304 
305  int normalF = 1;
306  if (bNomarlized) normalF = nx * ny;
307  memset(tmp, 0, sizeof(Complex)*nx*ny);
308 
309  for (int k = 0; k < nx*ny; k++) {
310  tmp[k].a = out[k][0] / normalF;
311  tmp[k].b = out[k][1] / normalF;
312  }
313 
314  fftw_free(in);
315  fftw_free(out);
316 
317  memset(dst, 0.0, sizeof(Complex)*nx*ny);
318  fftShift(nx, ny, tmp, dst);
319 
320  free(tmp);
321 
322 }
323 
332 void HologramGenerator::fftShift(int nx, int ny, Complex* input, Complex* output)
333 {
334  for (int i = 0; i < nx; i++)
335  {
336  for (int j = 0; j < ny; j++)
337  {
338  int ti = i - nx / 2; if (ti < 0) ti += nx;
339  int tj = j - ny / 2; if (tj < 0) tj += ny;
340 
341  output[ti + tj * nx] = input[i + j * nx];
342  }
343  }
344 }
345 
352 {
353  double realv = val->a;
354  double imgv = val->b;
355  val->a = exp(realv)*cos(imgv);
356  val->b = exp(realv)*sin(imgv);
357 
358 }
359 
367 void HologramGenerator::get_shift_phase_value(Complex& shift_phase_val, int idx, ivec2 sig_location)
368 {
369  int pnx = params_.pn[0];
370  int pny = params_.pn[1];
371  double ppx = params_.pp[0];
372  double ppy = params_.pp[1];
373  double ssx = params_.ss[0];
374  double ssy = params_.ss[1];
375 
376  if (sig_location[1] != 0)
377  {
378  int r = idx / pnx;
379  int c = idx % pnx;
380  double yy = (ssy / 2.0) - (ppy)*r - ppy;
381 
382  Complex val;
383  if (sig_location[1] == 1)
384  val.b = 2 * PI * (yy / (4 * ppy));
385  else
386  val.b = 2 * PI * (-yy / (4 * ppy));
387 
388  exponent_complex(&val);
389  shift_phase_val *= val;
390  }
391 
392  if (sig_location[0] != 0)
393  {
394  int r = idx / pnx;
395  int c = idx % pnx;
396  double xx = (-ssx / 2.0) - (ppx)*c - ppx;
397 
398  Complex val;
399  if (sig_location[0] == -1)
400  val.b = 2 * PI * (-xx / (4 * ppx));
401  else
402  val.b = 2 * PI * (xx / (4 * ppx));
403 
404  exponent_complex(&val);
405  shift_phase_val *= val;
406  }
407 
408 }
409 
410 
411 //=====Reconstruction =======================================================================
416 {
417  if (!u255_fringe_) {
418  //u255_fringe_ = (double*)malloc(sizeof(double)*params_.pn[0] * params_.pn[1]);
419  //if (!readMatFileDouble("u255_fringe.mat", u255_fringe_))
420  LOG("Error: No Hologram Data\n");
421  return;
422  }
423 
426 
429 
431 
432  if (sim_final_) free(sim_final_);
433  sim_final_ = (double*)malloc(sizeof(double)*SLM_pixel_number_xy_[0] * SLM_pixel_number_xy_[1]);
434  memset(sim_final_, 0.0, sizeof(double)*SLM_pixel_number_xy_[0] * SLM_pixel_number_xy_[1]);
435 
436  double vmax, vmin, vstep, vval;
437  if (sim_step_num_ > 1)
438  {
439  vmax = max(sim_to_, sim_from_);
440  vmin = min(sim_to_, sim_from_);
441  vstep = (sim_to_ - sim_from_) / (sim_step_num_ - 1);
442 
443  }
444  else if (sim_step_num_ == 1) {
445  vval = (sim_to_ + sim_from_) / 2.0;
446  }
447 
448  fftw_complex *in, *out;
449  fft_plan_fwd_ = fftw_plan_dft_2d(SLM_pixel_number_xy_[1], SLM_pixel_number_xy_[0], in, out, FFTW_FORWARD, FFTW_ESTIMATE);
450 
451  if (hh_complex_) free(hh_complex_);
452  hh_complex_ = (Complex*)malloc(sizeof(Complex) *SLM_pixel_number_xy_[0] * SLM_pixel_number_xy_[1]);
453 
455 
456  if (sim_step_num_ > 0)
457  {
458  for (int vtr = 1; vtr <= sim_step_num_; vtr++)
459  {
460  LOG("Calculating Frame %d of %d \n", vtr, sim_step_num_);
461  if (sim_step_num_ > 1)
462  vval = vmin + (vtr - 1)*vstep;
463  if (sim_type_ == 0)
464  focus_distance_ = vval;
465  else
466  eye_center_xy_[1] = vval;
467 
468  Reconstruction(in, out);
469  Write_Simulation_image(vtr, vval);
470  }
471 
472  }
473  else {
474 
475  Reconstruction(in, out);
477 
478  }
479 
480  fftw_destroy_plan(fft_plan_fwd_);
481  fftw_cleanup();
482 
483  free(hh_complex_);
484  free(sim_final_);
485  sim_final_ = 0;
486  hh_complex_ = 0;
487 
488 
489 }
490 
494 void HologramGenerator::Test_Propagation_to_Eye_Pupil(fftw_complex* in, fftw_complex* out)
495 {
496  int pnx = SLM_pixel_number_xy_[0];
497  int pny = SLM_pixel_number_xy_[1];
498  double ppx = Pixel_pitch_xy_[0];
499  double ppy = Pixel_pitch_xy_[1];
500  double F_size_x = pnx*ppx;
501  double F_size_y = pny*ppy;
502  double lambda = params_.lambda;
503 
504  Complex* hh = (Complex*)malloc(sizeof(Complex) * pnx*pny);
505 
506  for (int k = 0; k < pnx*pny; k++)
507  {
508  hh[k].a = u255_fringe_[k];
509  hh[k].b = 0.0;
510  }
511 
512  fftwShift(hh, hh, in, out, pnx, pny, 1, false);
513 
514  double pp_ex = lambda * f_field_ / F_size_x;
515  double pp_ey = lambda * f_field_ / F_size_y;
516  double E_size_x = pp_ex*pnx;
517  double E_size_y = pp_ey*pny;
518 
519  int p;
520 #pragma omp parallel for private(p)
521  for (p = 0; p < pnx * pny; p++)
522  {
523  double x = p % pnx;
524  double y = p / pnx;
525 
526  double xe = (-E_size_x / 2.0) + (pp_ex * x);
527  double ye = (E_size_y / 2.0 - pp_ey) - (pp_ey * y);
528 
529  double sval = PI / lambda / f_field_ * (xe*xe + ye*ye);
530  Complex kernel(0, sval);
531  exponent_complex(&kernel);
532 
533  hh_complex_[p] = hh[p] * kernel;
534 
535  }
536 
537  free(hh);
538 
539 }
540 
544 void HologramGenerator::Reconstruction(fftw_complex* in, fftw_complex* out)
545 {
546  int pnx = SLM_pixel_number_xy_[0];
547  int pny = SLM_pixel_number_xy_[1];
548  double ppx = Pixel_pitch_xy_[0];
549  double ppy = Pixel_pitch_xy_[1];
550  double F_size_x = pnx*ppx;
551  double F_size_y = pny*ppy;
552  double lambda = params_.lambda;
553  double pp_ex = lambda * f_field_ / F_size_x;
554  double pp_ey = lambda * f_field_ / F_size_y;
555  double E_size_x = pp_ex*pnx;
556  double E_size_y = pp_ey*pny;
557 
558  Complex* hh_e_shift = (Complex*)malloc(sizeof(Complex) * pnx*pny);
559  Complex* hh_e_ = (Complex*)malloc(sizeof(Complex) * pnx*pny);
560 
561  int eye_shift_by_pnx = round(eye_center_xy_[0] / pp_ex);
562  int eye_shift_by_pny = round(eye_center_xy_[1] / pp_ey);
563  circshift(hh_complex_, hh_e_shift, -eye_shift_by_pnx, eye_shift_by_pny, pnx, pny);
564 
566  double effective_f = f_eye*eye_length_ / (f_eye - eye_length_);
567 
568  int p;
569 #pragma omp parallel for private(p)
570  for (p = 0; p < pnx * pny; p++)
571  {
572  double x = p % pnx;
573  double y = p / pnx;
574 
575  double xe = (-E_size_x / 2.0) + (pp_ex * x);
576  double ye = (E_size_y / 2.0 - pp_ey) - (pp_ey * y);
577 
578  Complex eye_propagation_kernel(0, PI / lambda / effective_f * (xe*xe + ye*ye));
579  exponent_complex(&eye_propagation_kernel);
580  int eye_lens_anti_aliasing_mask = (sqrt(xe*xe + ye*ye) < abs(lambda*effective_f / (2.0 * max(pp_ex, pp_ey)))) ? 1 : 0;
581  int eye_pupil_mask = (sqrt(xe*xe + ye*ye) < (eye_pupil_diameter_ / 2.0)) ? 1 : 0;
582 
583  hh_e_[p] = hh_e_shift[p] * eye_propagation_kernel * eye_lens_anti_aliasing_mask * eye_pupil_mask;
584 
585  }
586 
587  fftwShift(hh_e_, hh_e_, in, out, pnx, pny, 1, false);
588 
589  double pp_ret_x = lambda*eye_length_ / E_size_x;
590  double pp_ret_y = lambda*eye_length_ / E_size_y;
591  double Ret_size_x = pp_ret_x*pnx;
592  double Ret_size_y = pp_ret_y*pny;
593 
594 #pragma omp parallel for private(p)
595  for (p = 0; p < pnx * pny; p++)
596  {
597  double x = p % pnx;
598  double y = p / pnx;
599 
600  double xr = (-Ret_size_x / 2.0) + (pp_ret_x * x);
601  double yr = (Ret_size_y / 2.0 - pp_ret_y) - (pp_ret_y * y);
602 
603  double sval = PI / lambda / eye_length_*(xr*xr + yr*yr);
604  Complex kernel(0, sval);
605  exponent_complex(&kernel);
606 
607  sim_final_[p] = (hh_e_[p] * kernel).mag();
608 
609  }
610 
611  free(hh_e_shift);
612  free(hh_e_);
613 
614 }
615 
620 {
621  QDir dir("./");
622  if (!dir.exists(QString().fromStdString(RESULT_FOLDER)))
623  dir.mkdir(QString().fromStdString(RESULT_FOLDER));
624 
625  QString fname = "./" + QString().fromStdString(RESULT_FOLDER) + "/"
626  + QString().fromStdString(Simulation_Result_File_Prefix_) + "_"
627  + QString().fromStdString(RESULT_PREFIX)
628  + QString().setNum(num)
629  + QString("_") + (sim_type_ == 0 ? "FOCUS_" : "EYE_Y_") + QString().setNum(round(val * 1000))
630  + ".bmp";
631 
632  int pnx = params_.pn[0];
633  int pny = params_.pn[1];
634  int px = pnx / 3;
635  int py = pny;
636 
637  double min_val, max_val;
638  min_val = sim_final_[0];
639  max_val = sim_final_[0];
640  for (int i = 0; i < pnx*pny; ++i)
641  {
642  if (min_val > sim_final_[i])
643  min_val = sim_final_[i];
644  else if (max_val < sim_final_[i])
645  max_val = sim_final_[i];
646  }
647 
648  uchar* data = (uchar*)malloc(sizeof(uchar)*pnx*pny);
649  memset(data, 0, sizeof(uchar)*pnx*pny);
650  for (int k = 0; k < pnx*pny; k++)
651  data[k] = (uint)((sim_final_[k] - min_val) / (max_val - min_val) * 255);
652 
653  QImage img(data, px, py, QImage::Format::Format_RGB888);
654  img.save(QString(fname));
655 
656  free(data);
657 
658 }
659 
663 void HologramGenerator::circshift(Complex* in, Complex* out, int shift_x, int shift_y, int nx, int ny)
664 {
665  int ti, tj;
666  for (int i = 0; i < nx; i++)
667  {
668  for (int j = 0; j < ny; j++)
669  {
670  ti = (i + shift_x) % nx;
671  if (ti < 0)
672  ti = ti + nx;
673  tj = (j + shift_y) % ny;
674  if (tj < 0)
675  tj = tj + ny;
676 
677  out[ti + tj * nx] = in[i + j * nx];
678  }
679  }
680 }
double sim_from_
reconstruction variable for testing
int sim_type_
reconstruction variable for testing
double * img_src_
CPU variable - image source data, values are from 0 to 1.
double dstep_
the physical increment of each depth map layer.
void Calc_Holo_CPU(int frame)
Main method for generating a hologram on the CPU.
void get_shift_phase_value(Complex &shift_phase_val, int idx, ivec2 sig_location)
Calculate the shift phase value.
uint num_of_depth
the number of depth level.
double * depth_index_
CPU variable - quantized depth map data.
void ReconstructImage()
It is a testing function used for the reconstruction.
double a
Definition: complex.h:145
Complex * U_complex_
CPU variable - the generated hologram before encoding.
uint DEFAULT_DEPTH_QUANTIZATION
default value of the depth quantization - 256
std::string RESULT_PREFIX
the prefix of the result file - config file
double k
2 * PI / lambda
real sum(const vec2 &a)
Definition: vec.h:377
double * sim_final_
reconstruction variable for testing
Complex * hh_complex_
reconstruction variable for testing
bool FLAG_CHANGE_DEPTH_QUANTIZATION
if true, change the depth quantization from the default value.
int * alpha_map_
CPU variable - calculated alpha map data, values are 0 or 1.
double far_depthmap
FAR_OF_DEPTH_MAP at config file.
void exponent_complex(Complex *val)
Calculate the exponential of the complex number.
double focus_distance_
reconstruction variable for testing
std::vector< double > dlevel_
the physical value of all depth map layer.
int Propagation_Method_
propagation method - currently AngularSpectrum
void circshift(Complex *in, Complex *out, int shift_x, int shift_y, int nx, int ny)
It is a testing function used for the reconstruction.
double lambda
WAVELENGTH at config file.
structure for 2-dimensional integer vector and its arithmetic.
Definition: ivec.h:14
ivec2 pn
SLM_PIXEL_NUMBER_X & SLM_PIXEL_NUMBER_Y.
void change_depth_quan_CPU()
Quantize depth map on the CPU, when the number of depth quantization is not the default value (i...
void Write_Simulation_image(int num, double val)
It is a testing function used for the reconstruction.
std::string Simulation_Result_File_Prefix_
reconstruction variable for testing
std::vector< int > render_depth
Used when only few specific depth levels are rendered, usually for test purpose.
double field_lens
FIELD_LENS at config file.
int sim_step_num_
reconstruction variable for testing
void fftwShift(Complex *src, Complex *dst, fftw_complex *in, fftw_complex *out, int nx, int ny, int type, bool bNomalized=false)
Convert data from the spatial domain to the frequency domain using 2D FFT on CPU. ...
double eye_length_
reconstruction variable for testing
void Reconstruction(fftw_complex *in, fftw_complex *out)
It is a testing function used for the reconstruction.
void fftShift(int nx, int ny, Complex *input, Complex *output)
Swap the top-left quadrant of data with the bottom-right , and the top-right quadrant with the bottom...
int test_pixel_number_scale_
reconstruction variable for testing
double f_field_
reconstruction variable for testing
double b
Definition: complex.h:145
class for the complex number and its arithmetic.
Definition: complex.h:22
double sim_to_
reconstruction variable for testing
vec2 eye_center_xy_
reconstruction variable for testing
double * dmap_
CPU variable - physical distances of depth map.
ivec2 SLM_pixel_number_xy_
reconstruction variable for testing
vec2 pp
SLM_PIXEL_PITCH_X & SLM_PIXEL_PITCH_Y.
double * u255_fringe_
the final hologram, used for writing the result image.
bool prepare_inputdata_CPU(uchar *img, uchar *dimg)
Preprocess input image & depth map data for the CPU implementation.
vec2 Pixel_pitch_xy_
reconstruction variable for testing
void init_CPU()
Initialize variables for the CPU implementation.
void Propagation_AngularSpectrum_CPU(Complex *input_u, double propagation_dist)
Angular spectrum propagation method for CPU implementation.
fftw_plan fft_plan_fwd_
double * dmap_src_
CPU variable - depth map data, values are from 0 to 1.
double eye_pupil_diameter_
reconstruction variable for testing
fftw_plan fft_plan_bwd_
std::vector< double > dlevel_transform_
transfomed dlevel_ variable
std::string RESULT_FOLDER
the name of the result folder - config file
double near_depthmap
NEAR_OF_DEPTH_MAP at config file.
void get_rand_phase_value(Complex &rand_phase_val)
Assign random phase value if RANDOM_PHASE == 1.
void encoding_CPU(int cropx1, int cropx2, int cropy1, int cropy2, ivec2 sig_location)
Encode the CGH according to a signal location parameter on the CPU.
HologramParams params_
structure variable for hologram parameters
void Test_Propagation_to_Eye_Pupil(fftw_complex *in, fftw_complex *out)
It is a testing function used for the reconstruction.
const double PI
Definition: complex.h:16