Openholo  v2.1
Open Source Digital Holographic Library
ophLightField.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 __ophLightField_h
47 #define __ophLightField_h
48 
49 #include "ophGen.h"
50 #include <fstream>
51 #include <io.h>
52 
53 using namespace oph;
54 
55 
56 //Build Option : Multi Core Processing (OpenMP)
57 #ifdef _OPENMP
58 #include <omp.h>
59 #endif
60 
63 
90 
97 class GEN_DLL ophLF : public ophGen
98 {
99 public:
103  explicit ophLF(void);
104 
105 protected:
109  virtual ~ophLF(void) {}
110 
111 private:
112  std::vector<int> m_vecImgSize;
113  std::vector<uchar *> m_vecImages; // Light Field array / 4-D array
114  std::vector<Complex<Real>*> m_vecRSplane;
115  //Complex<Real>** RSplane_complex_field; /// Complex field in Ray Sampling plane
116 
117 
118 private:
119 
120  // Light Field save parameters
121 
122  const char* LF_directory;
123  const char* ext;
124 
125 public:
126  inline void setNumImage(int nx, int ny) { num_image[_X] = nx; num_image[_Y] = ny; }
127  inline void setNumImage(ivec2 num) { num_image = num; }
128  inline void setResolImage(int nx, int ny) { resolution_image[_X] = nx; resolution_image[_Y] = ny; }
129  inline void setResolImage(ivec2 num) { resolution_image = num; }
130  inline void setDistRS2Holo(Real dist) { distanceRS2Holo = dist; }
131  inline void setFieldLens(Real lens) { fieldLens = lens; }
132  inline ivec2 getNumImage() { return num_image; }
133  inline ivec2 getResolImage() { return resolution_image; }
134  inline Real getDistRS2Holo() { return distanceRS2Holo; }
135  inline Real getFieldLens() { return fieldLens; }
136  inline vector<uchar*> getLF() { return m_vecImages; }
137  inline vector<Complex<Real>*> getRSPlane() { return m_vecRSplane; }
138 public:
149  bool readConfig(const char* fname);
150 
158  int loadLF(const char* directory, const char* exten);
159  int loadLF();
160  //void readPNG(const string filename, uchar* data);
161 
166  void generateHologram();
167 
168  // for Testing
169  void writeIntensity_gray8_bmp(const char* fileName, int nx, int ny, Complex<Real>* complexvalue, int k = -1);
179  void setViewingWindow(bool is_ViewingWindow);
180 protected:
181 
182  // Inner functions
183 
184  void initializeLF();
185  void convertLF2ComplexField();
186 
187  // ==== GPU Methods ===============================================
188  void convertLF2ComplexField_GPU();
189 
190  void ophFree();
191 
192 private:
193 
194  ivec2 num_image;
195  ivec2 resolution_image;
196  Real distanceRS2Holo;
197  Real fieldLens;
198  bool is_ViewingWindow;
199  int nImages;
200 };
201 
202 
203 #endif
vector< Complex< Real > * > getRSPlane()
#define GEN_DLL
Definition: ophGen.h:54
void setNumImage(int nx, int ny)
#define _Y
Definition: define.h:84
Openholo Light Field based CGH generation.
Definition: ophLightField.h:97
ivec2 getResolImage()
void setNumImage(ivec2 num)
def k(wvl)
Definition: Depthmap.py:16
virtual ~ophLF(void)
Destructor.
vector< uchar * > getLF()
void setDistRS2Holo(Real dist)
void setResolImage(ivec2 num)
Real getDistRS2Holo()
void setResolImage(int nx, int ny)
float Real
Definition: typedef.h:55
ivec2 getNumImage()
#define _X
Definition: define.h:80
Definition: Bitmap.h:49
void setFieldLens(Real lens)
Real getFieldLens()
Definition: ophGen.h:68