Openholo  v2.1
Open Source Digital Holographic Library
ophPAS.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef __ophPAS_h
4 #define __ophPAS_h
5 
6 #include "ophGen.h"
7 
8 
9 #define PI (3.14159265358979323846f)
10 #define M2_PI (PI*2.0)
11 #define RADIANS (PI/180.0) // Angle in radians
12 // DEGREE*asin(mytheta)
13 #define DEGREE2 (180./PI) // sin(RADIANS*DEGREE*asin(mytheta))
14 
15 #define NUMTBL 1024
16 #define NUMTBL2 (NUMTBL-1)
17 #define MAX_STR_LEN 4000
18 
19 #define FFT_SEGMENT_SIZE 64
20 
21 struct VoxelStruct;
22 struct Segment;
23 
24 using namespace oph;
25 
26 class GEN_DLL ophPAS : public ophGen
27 {
28 private:
29  OphPointCloudConfig pc_config;
30  OphPointCloudData pc_data;
31  int n_points;
32 public:
33  explicit ophPAS();
34 protected:
35  virtual ~ophPAS();
36 
37 public:
38 
39 
40 
41  bool readConfig(const char* fname);
42  int loadPoint(const char* _filename);
43 
44  //int saveAsImg(const char * fname, uint8_t bitsperpixel, void* src, int pic_width, int pic_height); // À̹ÌÁö ÀúÀå
45  int save(const char * fname, uint8_t bitsperpixel, uchar* src, uint px, uint py);
46  void save(const char* fname);
47 
48 
49 
50 
51  //void PASCalcuation(long voxnum, unsigned char *cghfringe, VoxelStruct* h_vox, CGHEnvironmentData* _CGHE);
52  void PASCalculation(long voxnum, unsigned char * cghfringe, OphPointCloudData *data, OphPointCloudConfig& conf);
53  //void PAS(long voxelnum, struct VoxelStruct *voxel, double *m_pHologram, CGHEnvironmentData* _CGHE);
54  void PAS(long voxelnum, OphPointCloudData *data, double *m_pHologram, OphPointCloudConfig& conf);
55  void PAS_GPU(long voxelnum, OphPointCloudData *data, double *m_pHologram, OphPointCloudConfig& conf);
56  void DataInit(int segsize, int cghwidth, int cghheight, float xiinter, float etainter);
57  void DataInit(OphPointCloudConfig& conf);
58  void MemoryRelease(void);
59 
60  void generateHologram();
61 
62  void CalcSpatialFrequency(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float * xc, float * yc, float * sf_cx, float * sf_cy, int * pp_cx, int * pp_cy, int * cf_cx, int * cf_cy, float xiint, float etaint, OphPointCloudConfig& conf);
63 
64  void CalcCompensatedPhase(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float *xc, float *yc, int *cf_cx, int *cf_cy, float *COStbl, float *SINtbl, float **inRe, float **inIm, OphPointCloudConfig& conf);
65 
66  void RunFFTW(int segnumx, int segnumy, int segsize, int hsegsize, float **inRe, float **inIm, fftw_complex *in, fftw_complex *out, fftw_plan *plan, double *pHologram, OphPointCloudConfig& conf);
67 
68  void encodeHologram(const vec2 band_limit, const vec2 spectrum_shift);
69  void encoding(unsigned int ENCODE_FLAG);
70 
71 
72  double *m_pHologram;
73 
74  float m_COStbl[NUMTBL];
75  float m_SINtbl[NUMTBL];
76 
77  int m_segSize;
78  int m_hsegSize;
79  int m_dsegSize;
80  int m_segNumx;
81  int m_segNumy;
82  int m_hsegNumx;
83  int m_hsegNumy;
84 
85  float* m_inRe_h;
86  float* m_inIm_h;
87 
88  float *m_SFrequency_cx;
89  float *m_SFrequency_cy;
90  int *m_PickPoint_cx;
91  int *m_PickPoint_cy;
92  int *m_Coefficient_cx;
93  int *m_Coefficient_cy;
94  float *m_xc;
95  float *m_yc;
96  unsigned char* cgh_fringe;
97 
98  float m_sf_base;
99 
100  fftw_complex *m_in, *m_out;
101  fftw_plan m_plan;
102 
103  float **m_inRe;
104  float **m_inIm;
105 
106  float m_cx;
107  float m_cy;
108  float m_cz;
109  float m_amp;
110 };
111 
112 struct GEN_DLL VoxelStruct // voxel structure - data
113 {
114  int num; // voxel or point number
115  float x; // x axis coordinate
116  float y; // y axis coordinate
117  float z; // z axis coordinate
118  float ph; // phase
119  float r; // amplitude in red channel
120  float g; // amplitude in green channel
121  float b; // amplitude in blue channel
122 };
123 
124 
125 struct GEN_DLL Segment
126 {
127  bool WorkingFlag;
128  long SegmentIndex;
129  int SegSize_x;
130  int SegSize_y;
131  int hSegSize_x; // Half size
132  int hSegSize_y; // Half size
133  double CenterX;
134  double CenterY;
135  double FrequencySlope;
136 };
137 #endif // !__ophPAS_h
unsigned char uchar
Definition: typedef.h:64
#define GEN_DLL
Definition: ophGen.h:54
Configuration for Point Cloud.
Definition: ophGen.h:522
Data for Point Cloud.
Definition: ophGen.h:549
Definition: ophPAS.h:26
Definition: Bitmap.h:49
#define NUMTBL
Definition: ophPAS.h:15
unsigned int uint
Definition: typedef.h:62
Definition: ophGen.h:68