Openholo  v4.2
Open Source Digital Holographic Library
ophRec.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 
46 #ifndef __OphReconstruction_h
47 #define __OphReconstruction_h
48 
49 #include "Openholo.h"
50 
51 #ifdef RECON_EXPORT
52 #define RECON_DLL __declspec(dllexport)
53 #else
54 #define RECON_DLL __declspec(dllimport)
55 #endif
56 
57 
59 {
77  bool SimulationPos[3];
78 };
79 
85 class RECON_DLL ophRec : public Openholo
86 {
87 public:
91  explicit ophRec(void);
92 
93 protected:
97  virtual ~ophRec(void);
98 
99 
100 private:
101  vector<Real *> m_vecEncoded;
102  vector<uchar *> m_vecNormalized;
103 
104  std::vector<Complex<Real>*> field_set_;
105  std::vector<double*> field_ret_set_;
106 
107  std::vector<double*> res_set_;
108  std::vector<double*> res_set_norm_255_;
109 
110  std::vector<ivec2> pn_set_; // Pixel number of output plane
111  std::vector<vec2> pp_set_; // Pixel pitch of output plane
112  std::vector<ivec2> pn_ret_set_;
113  std::vector<vec2> pp_ret_set_;
114  std::vector<vec2> ss_ret_set_;
115 
116  std::vector<Real*> recon_set;
117  std::vector<uchar*> img_set;
118  std::vector<ivec2> img_size;
119  std::vector<Real*> focus_recon_set;
120  std::vector<uchar*> focus_img_set;
121  std::vector<ivec2> focus_img_size;
122 
123  int m_oldSimStep;
124 
125 
126  OphRecConfig rec_config;
127  int m_nOldChannel;
128  int m_idx;
129  unsigned int m_mode;
130 
131 protected:
135  virtual void ophFree(void);
136  void Clear();
137  void GetPupilFieldFromHologram();
138  void GetPupilFieldFromVWHologram();
139  void Propagation_Fresnel_FFT(int chnum);
140  void ASM_Propagation();
141  void ASM_Propagation_GPU();
142  void GetPupilFieldImage(Complex<Real>* src, double* dst, int pnx, int pny, double ppx, double ppy, double scaleX, double scaleY);
143  void getVarname(int vtr, vec3& var_vals, std::string& varname2);
144 public:
145  void SaveImage(const char* path, const char* ext = "bmp");
146  void setConfig(OphRecConfig config) { rec_config = config; }
147  void SetMode(unsigned int mode) { m_mode = mode; }
148  OphRecConfig& getConfig() { return rec_config; }
149  bool ReconstructImage();
150  bool readConfig(const char* fname);
151  bool readImage(const char* path);
152  bool readImagePNA(const char* phase, const char* amplitude);
153  bool readImageRNI(const char* real, const char* imaginary);
154  void Perform_Simulation();
155  void Initialize();
156  bool save(const char * fname, uint8_t bitsperpixel, uchar* src, uint px, uint py);
157  template<typename T>
158  void normalize(T* src, uchar* dst, int x, int y);
159  template<typename T>
160  void normalize(T* src, uchar* dst, int x, int y, T max, T min);
161 
162 };
163 
164 
165 #endif // !__OphReconstruction_h
Real SimulationTo
Definition: ophRec.h:68
Real RatioAtRetina
Definition: ophRec.h:72
Abstract class.
Definition: Openholo.h:145
int SimulationStep
Definition: ophRec.h:70
Real SimulationFrom
Definition: ophRec.h:69
unsigned char uchar
Definition: typedef.h:64
void SetMode(unsigned int mode)
Definition: ophRec.h:147
Real EyeBoxSizeScale
Definition: ophRec.h:62
bool ViewingWindow
Definition: ophRec.h:76
vec3 EyeCenter
Definition: ophRec.h:65
#define RECON_DLL
Definition: ophRec.h:54
Definition: ophRec.h:85
float Real
Definition: typedef.h:55
void normalize(const Complex< T > *src, Complex< T > *dst, const int &size)
Normalize all elements of Complex<T>* src from 0 to 1.
Definition: function.h:176
vec2 EyeBoxSize
Definition: ophRec.h:63
bool CreatePupilFieldImg
Definition: ophRec.h:74
Real RatioAtPupil
Definition: ophRec.h:73
Real EyeFocusDistance
Definition: ophRec.h:66
void setConfig(OphRecConfig config)
Definition: ophRec.h:146
OphRecConfig & getConfig()
Definition: ophRec.h:148
Real EyePupilDiaMeter
Definition: ophRec.h:61
structure for 2-dimensional Real type vector and its arithmetic.
Definition: vec.h:66
int SimulationMode
Definition: ophRec.h:71
structure for 3-dimensional Real type vector and its arithmetic.
Definition: vec.h:466
Real EyeLength
Definition: ophRec.h:60
bool CenteringRetinaImg
Definition: ophRec.h:75
int EyeBoxUnit
Definition: ophRec.h:64
Real ResultSizeScale
Definition: ophRec.h:67
unsigned int uint
Definition: typedef.h:62
virtual void ophFree(void)
Pure virtual function for override in child classes.
Definition: Openholo.cpp:805