Openholo  v4.0
Open Source Digital Holographic Library
ophCascadedPropagation.h
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install, copy or use the software.
7 //
8 //
9 // License Agreement
10 // For Open Source Digital Holographic Library
11 //
12 // Openholo library is free software;
13 // you can redistribute it and/or modify it under the terms of the BSD 2-Clause license.
14 //
15 // Copyright (C) 2017-2024, Korea Electronics Technology Institute. All rights reserved.
16 // E-mail : contact.openholo@gmail.com
17 // Web : http://www.openholo.org
18 //
19 // Redistribution and use in source and binary forms, with or without modification,
20 // are permitted provided that the following conditions are met:
21 //
22 // 1. Redistribution's of source code must retain the above copyright notice,
23 // this list of conditions and the following disclaimer.
24 //
25 // 2. Redistribution's in binary form must reproduce the above copyright notice,
26 // this list of conditions and the following disclaimer in the documentation
27 // and/or other materials provided with the distribution.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the copyright holder or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 // This software contains opensource software released under GNU Generic Public License,
41 // NVDIA Software License Agreement, or CUDA supplement to Software License Agreement.
42 // Check whether software you use contains licensed software.
43 //
44 //M*/
45 #pragma once
46 #ifndef _OphCascadedPropagation_h
47 #define _OphCascadedPropagation_h
48 
49 #include "ophRec.h"
50 
51 enum SourceType {IMG, OHC};
52 
55  : num_colors(0),
56  wavelengths{ 0.0, 0.0, 0.0 },
57  dx(0.0),
58  dy(0.0),
59  nx(0),
60  ny(0),
64  pupil_diameter(0.0),
65  nor(0.0)
66  {}
67 
72 
77 
82 
87 
92 
97 
102 
107 
112 
117 
122 };
123 
127 
152 
160  private:
165 
166  public:
171  ophCascadedPropagation(const wchar_t* configfilepath);
172 
177 
183  bool propagate();
184 
192  bool save(const wchar_t* pathname, uint8_t bitsperpixel);
193 
197  virtual bool saveAsOhc(const char *fname);
198 
202  virtual bool loadAsOhc(const char *fname);
203 
204 
205  private:
209  SourceType sourcetype_;
210 
215 
219  vector<oph::Complex<Real>*> wavefield_SLM;
220 
224  vector<oph::Complex<Real>*> wavefield_pupil;
225 
229  vector<oph::Complex<Real>*> wavefield_retina;
230 
234  bool ready_to_propagate;
235 
239  wstring hologram_path;
240 
246  bool readConfig(const wchar_t* fname);
247 
253  bool allocateMem();
254 
258  void deallocateMem();
259 
265  bool loadInputImg(string hologram_path_str);
266 
274  oph::uchar* getIntensityfields(vector<oph::Complex<Real>*> wavefields);
275 
276 
277  public:
281  bool isReadyToPropagate() { return ready_to_propagate; }
282 
286  oph::uint getNumColors() { return config_.num_colors; }
287 
291  oph::vec3 getWavelengths() { return config_.wavelengths; }
292 
296  Real getPixelPitchX() { return config_.dx; }
297 
301  Real getPixelPitchY() { return config_.dy; }
302 
306  oph::uint getResX() { return config_.nx; }
307 
311  oph::uint getResY() { return config_.ny; }
312 
317 
322 
327 
331  Real getPupilDiameter() { return config_.pupil_diameter; }
332 
337  Real getNor() { return config_.nor; }
338 
342  oph::Complex<Real>* getSlmWavefield(oph::uint id);
343 
347  oph::Complex<Real>* getPupilWavefield(oph::uint id);
348 
352  oph::Complex<Real>* getRetinaWavefield(oph::uint id);
353 
357  vector<oph::Complex<Real>*> getRetinaWavefieldAll();
358 
359 
360  // setters
361  //virtual bool SetSlmWavefield(Complex<Real>* srcHologram) = 0; // set input wavefield (for later use)
362  //virtual bool SetSlmWavefield(ophGen& srcHologram) = 0; // set input wavefield (for later use)
363 
369  bool propagateSlmToPupil();
370 
376  bool propagatePupilToRetina();
377 
378 
379  protected:
383  virtual void ophFree(void);
384 };
385 
386 
387 
388 // utilities
389 #define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
390 #define PRINT_ERROR(errorMsg) { cout << "Error(" << __FILENAME__ << ":" << __LINE__ << "): " << ( errorMsg ) << endl; }
391 
392 #endif
oph::uint getResX()
Returns horizontal resolution.
Real getPupilDiameter()
Returns diameter of pupil in meter.
Real getDistPupilToRetina()
Returns distance from pupil plane to retina plane in meter.
unsigned char uchar
Definition: typedef.h:64
float Real
Definition: typedef.h:55
Real getFieldLensFocalLength()
Returns focal length of field lens in meter.
Definition: ophRec.h:104
virtual void ophFree(void)
Pure virtual function for override in child classes.
Definition: ophRec.cpp:1519
oph::uint getResY()
Returns vertical resolution.
oph::vec3 getWavelengths()
Returns wavelengths in meter.
bool isReadyToPropagate()
Returns if all data are prepared.
structure for 3-dimensional Real type vector and its arithmetic.
Definition: vec.h:466
#define RECON_DLL
Definition: ophRec.h:61
Real getPixelPitchY()
Returns vertical pixel pitch in meter.
bool save(const char *fname, uint8_t bitsperpixel, uchar *src, uint px, uint py)
Definition: ophRec.cpp:1204
virtual bool loadAsOhc(const char *fname)
Function to read OHC file.
Definition: Openholo.cpp:280
Cascaded propagation module.
virtual bool saveAsOhc(const char *fname)
Function to write OHC file
Definition: Openholo.cpp:252
bool readConfig(const char *fname)
Definition: ophRec.cpp:74
Real getPixelPitchX()
Returns horizontal pixel pitch in meter.
Real getDistObjectToPupil()
Returns distance from reconstruction plane to pupil plane in meter.
oph::uint getNumColors()
Returns number of colors.
unsigned int uint
Definition: typedef.h:62
Real getNor()
Returns Nor, which affects the range of output intensity.