Openholo  v4.0
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 using namespace oph;
51 
52 
53 //Build Option : Multi Core Processing (OpenMP)
54 #ifdef _OPENMP
55 #include <omp.h>
56 #endif
57 
60 
87 
94 class GEN_DLL ophLF : public ophGen
95 {
96 public:
100  explicit ophLF(void);
101 
102 protected:
106  virtual ~ophLF(void) {}
107 
108 public:
109  inline void setNumImage(int nx, int ny) { num_image[_X] = nx; num_image[_Y] = ny; }
110  inline void setNumImage(ivec2 num) { num_image = num; }
111  inline void setResolImage(int nx, int ny) { resolution_image[_X] = nx; resolution_image[_Y] = ny; }
112  inline void setResolImage(ivec2 num) { resolution_image = num; }
113  inline void setDistRS2Holo(Real dist) { distanceRS2Holo = dist; }
114  inline void setFieldLens(Real lens) { fieldLens = lens; }
115  inline ivec2 getNumImage() { return num_image; }
116  inline ivec2 getResolImage() { return resolution_image; }
117  inline Real getDistRS2Holo() { return distanceRS2Holo; }
118  inline Real getFieldLens() { return fieldLens; }
119  inline vector<uchar*> getLF() { return m_vecImages; }
120  inline vector<Complex<Real>*> getRSPlane() { return m_vecRSplane; }
121 public:
132  bool readConfig(const char* fname);
133 
141  int loadLF(const char* directory, const char* exten);
142  //void readPNG(const string filename, uchar* data);
143 
148  void generateHologram();
149 
150  // for Testing
151  void writeIntensity_gray8_bmp(const char* fileName, int nx, int ny, Complex<Real>* complexvalue, int k = -1);
161  void setViewingWindow(bool is_ViewingWindow);
162 protected:
163 
164  // Inner functions
165 
166  void initializeLF();
167  void convertLF2ComplexField();
168 
169  // ==== GPU Methods ===============================================
170  void convertLF2ComplexField_GPU();
171 
172  void ophFree();
173 
174 private:
175  ivec2 num_image;
176  ivec2 resolution_image;
177  Real distanceRS2Holo;
178  Real fieldLens;
179  bool is_ViewingWindow;
180  int nImages;
181  std::vector<int> m_vecImgSize;
182  std::vector<uchar*> m_vecImages; // Light Field array / 4-D array
183  std::vector<Complex<Real>*> m_vecRSplane;
184  //Complex<Real>** RSplane_complex_field; /// Complex field in Ray Sampling plane
185 };
186 
187 
188 #endif
vector< Complex< Real > * > getRSPlane()
float Real
Definition: typedef.h:55
void setNumImage(int nx, int ny)
structure for 2-dimensional integer vector and its arithmetic.
Definition: ivec.h:66
Openholo Light Field based CGH generation.
Definition: ophLightField.h:94
ivec2 getResolImage()
#define _Y
Definition: define.h:96
void setNumImage(ivec2 num)
#define _X
Definition: define.h:92
virtual ~ophLF(void)
Destructor.
vector< uchar * > getLF()
#define GEN_DLL
Definition: ophGen.h:61
void setDistRS2Holo(Real dist)
void setResolImage(ivec2 num)
Real getDistRS2Holo()
void setResolImage(int nx, int ny)
ivec2 getNumImage()
Definition: Bitmap.h:49
void setFieldLens(Real lens)
Real getFieldLens()
Definition: ophGen.h:76