HologramDepthmap Library
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HologramGenerator Class Reference

Main class for generating a hologram using depth map data. More...

#include <HologramGenerator.h>

Public Member Functions

 HologramGenerator ()
 Constructor. More...
 
 ~HologramGenerator ()
 Destructor. More...
 
void setMode (bool isCPU)
 Set the value of a variable isCPU_(true or false) More...
 
bool readConfig ()
 Read parameters from a config file(config_openholo.txt). More...
 
void initialize ()
 Initialize variables for CPU and GPU implementation. More...
 
void GenerateHologram ()
 Generate a hologram, main funtion. More...
 
void ReconstructImage ()
 It is a testing function used for the reconstruction. More...
 

Private Member Functions

void get_rand_phase_value (Complex &rand_phase_val)
 Assign random phase value if RANDOM_PHASE == 1. More...
 
void get_shift_phase_value (Complex &shift_phase_val, int idx, ivec2 sig_location)
 Calculate the shift phase value. More...
 
void fftwShift (Complex *src, Complex *dst, fftw_complex *in, fftw_complex *out, int nx, int ny, int type, bool bNomalized=false)
 Convert data from the spatial domain to the frequency domain using 2D FFT on CPU. More...
 
void exponent_complex (Complex *val)
 Calculate the exponential of the complex number. More...
 
void fftShift (int nx, int ny, Complex *input, Complex *output)
 Swap the top-left quadrant of data with the bottom-right , and the top-right quadrant with the bottom-left. More...
 
void init_CPU ()
 Initialize variables for the CPU implementation. More...
 
void init_GPU ()
 Initialize variables for the GPU implementation. More...
 
bool ReadImageDepth (int ftr)
 Read image and depth map. More...
 
bool prepare_inputdata_CPU (uchar *img, uchar *dimg)
 Preprocess input image & depth map data for the CPU implementation. More...
 
bool prepare_inputdata_GPU (uchar *img, uchar *dimg)
 Copy input image & depth map data into a GPU. More...
 
void GetDepthValues ()
 Calculate the physical distances of depth map layers. More...
 
void change_depth_quan_CPU ()
 Quantize depth map on the CPU, when the number of depth quantization is not the default value (i.e. FLAG_CHANGE_DEPTH_QUANTIZATION == 1 ). More...
 
void change_depth_quan_GPU ()
 Quantize depth map on the GPU, when the number of depth quantization is not the default value (i.e. FLAG_CHANGE_DEPTH_QUANTIZATION == 1 ). More...
 
void TransformViewingWindow ()
 Transform target object to reflect the system configuration of holographic display. More...
 
void Calc_Holo_by_Depth (int frame)
 Generate a hologram. More...
 
void Calc_Holo_CPU (int frame)
 Main method for generating a hologram on the CPU. More...
 
void Calc_Holo_GPU (int frame)
 Main method for generating a hologram on the GPU. More...
 
void Propagation_AngularSpectrum_CPU (Complex *input_u, double propagation_dist)
 Angular spectrum propagation method for CPU implementation. More...
 
void Propagation_AngularSpectrum_GPU (cufftDoubleComplex *input_u, double propagation_dist)
 Angular spectrum propagation method for GPU implementation. More...
 
void Encoding_Symmetrization (ivec2 sig_location)
 Encode the CGH according to a signal location parameter. More...
 
void encoding_CPU (int cropx1, int cropx2, int cropy1, int cropy2, ivec2 sig_location)
 Encode the CGH according to a signal location parameter on the CPU. More...
 
void encoding_GPU (int cropx1, int cropx2, int cropy1, int cropy2, ivec2 sig_location)
 Encode the CGH according to a signal location parameter on GPU. More...
 
void Write_Result_image (int ftr)
 Write the result image. More...
 
void Reconstruction (fftw_complex *in, fftw_complex *out)
 It is a testing function used for the reconstruction. More...
 
void Test_Propagation_to_Eye_Pupil (fftw_complex *in, fftw_complex *out)
 It is a testing function used for the reconstruction. More...
 
void Write_Simulation_image (int num, double val)
 It is a testing function used for the reconstruction. More...
 
void circshift (Complex *in, Complex *out, int shift_x, int shift_y, int nx, int ny)
 It is a testing function used for the reconstruction. More...
 

Private Attributes

bool isCPU_
 if true, it is implemented on the CPU, otherwise on the GPU. More...
 
unsigned char * img_src_gpu_
 GPU variable - image source data, values are from 0 to 255. More...
 
unsigned char * dimg_src_gpu_
 GPU variable - depth map data, values are from 0 to 255. More...
 
double * depth_index_gpu_
 GPU variable - quantized depth map data. More...
 
double * img_src_
 CPU variable - image source data, values are from 0 to 1. More...
 
double * dmap_src_
 CPU variable - depth map data, values are from 0 to 1. More...
 
double * depth_index_
 CPU variable - quantized depth map data. More...
 
int * alpha_map_
 CPU variable - calculated alpha map data, values are 0 or 1. More...
 
double * dmap_
 CPU variable - physical distances of depth map. More...
 
double dstep_
 the physical increment of each depth map layer. More...
 
std::vector< double > dlevel_
 the physical value of all depth map layer. More...
 
std::vector< double > dlevel_transform_
 transfomed dlevel_ variable More...
 
ComplexU_complex_
 CPU variable - the generated hologram before encoding. More...
 
double * u255_fringe_
 the final hologram, used for writing the result image. More...
 
HologramParams params_
 structure variable for hologram parameters More...
 
std::string SOURCE_FOLDER
 input source folder - config file. More...
 
std::string IMAGE_PREFIX
 the prefix of the input image file - config file. More...
 
std::string DEPTH_PREFIX
 the prefix of the deptmap file - config file More...
 
std::string RESULT_FOLDER
 the name of the result folder - config file More...
 
std::string RESULT_PREFIX
 the prefix of the result file - config file More...
 
bool FLAG_STATIC_IMAGE
 if true, the input image is static. More...
 
uint START_OF_FRAME_NUMBERING
 the start frame number. More...
 
uint NUMBER_OF_FRAME
 the total number of the frame. More...
 
uint NUMBER_OF_DIGIT_OF_FRAME_NUMBERING
 the number of digit of frame number. More...
 
int Transform_Method_
 transform method More...
 
int Propagation_Method_
 propagation method - currently AngularSpectrum More...
 
int Encoding_Method_
 encoding method - currently Symmetrization More...
 
double WAVELENGTH
 wave length More...
 
bool FLAG_CHANGE_DEPTH_QUANTIZATION
 if true, change the depth quantization from the default value. More...
 
uint DEFAULT_DEPTH_QUANTIZATION
 default value of the depth quantization - 256 More...
 
uint NUMBER_OF_DEPTH_QUANTIZATION
 depth level of input depthmap. More...
 
bool RANDOM_PHASE
 If true, random phase is imposed on each depth layer. More...
 
std::string Simulation_Result_File_Prefix_
 reconstruction variable for testing More...
 
int test_pixel_number_scale_
 reconstruction variable for testing More...
 
vec2 Pixel_pitch_xy_
 reconstruction variable for testing More...
 
ivec2 SLM_pixel_number_xy_
 reconstruction variable for testing More...
 
double f_field_
 reconstruction variable for testing More...
 
double eye_length_
 reconstruction variable for testing More...
 
double eye_pupil_diameter_
 reconstruction variable for testing More...
 
vec2 eye_center_xy_
 reconstruction variable for testing More...
 
double focus_distance_
 reconstruction variable for testing More...
 
int sim_type_
 reconstruction variable for testing More...
 
double sim_from_
 reconstruction variable for testing More...
 
double sim_to_
 reconstruction variable for testing More...
 
int sim_step_num_
 reconstruction variable for testing More...
 
double * sim_final_
 reconstruction variable for testing More...
 
Complexhh_complex_
 reconstruction variable for testing More...
 

Detailed Description

This is a main class for generating a digital hologram using depth map data. It is implemented on the CPU and GPU.

  1. Read Config file. - to set all parameters needed for generating a hologram.
  2. Initialize all variables. - memory allocation on the CPU and GPU.
  3. Generate a digital hologram using depth map data.
  4. For the testing purpose, reconstruct a image from the generated hologram.

Definition at line 130 of file HologramGenerator.h.

Constructor & Destructor Documentation

◆ HologramGenerator()

HologramGenerator::HologramGenerator ( )

Initialize variables.

Definition at line 15 of file HologramGenerator.cpp.

◆ ~HologramGenerator()

HologramGenerator::~HologramGenerator ( )

Definition at line 43 of file HologramGenerator.cpp.

Member Function Documentation

◆ exponent_complex()

void HologramGenerator::exponent_complex ( Complex val)
private
Parameters
val: input & ouput value
See also
Propagation_AngularSpectrum_CPU, Calc_Holo_CPU

Definition at line 351 of file HologramGenerator_CPU.cpp.

◆ fftShift()

void HologramGenerator::fftShift ( int  nx,
int  ny,
Complex input,
Complex output 
)
private
Parameters
nx: the number of column of the input data
ny: the number of row of the input data
input: input data variable
output: output data variable
See also
fftwShift

Definition at line 332 of file HologramGenerator_CPU.cpp.

◆ fftwShift()

void HologramGenerator::fftwShift ( Complex src,
Complex dst,
fftw_complex *  in,
fftw_complex *  out,
int  nx,
int  ny,
int  type,
bool  bNomarlized = false 
)
private

It is equivalent to Matlab code, dst = ifftshift(fft2(fftshift(src))).

Parameters
src: input data variable
dst: output data variable
in: input data pointer connected with FFTW plan
out: ouput data pointer connected with FFTW plan
nx: the number of column of the input data
ny: the number of row of the input data
type: If type == 1, forward FFT, if type == -1, backward FFT.
bNomarlized: If bNomarlized == true, normalize the result after FFT.
See also
Propagation_AngularSpectrum_CPU, encoding_CPU

Definition at line 285 of file HologramGenerator_CPU.cpp.

◆ get_rand_phase_value()

void HologramGenerator::get_rand_phase_value ( Complex rand_phase_val)
private

If RANDOM_PHASE == 1, calculate a random phase value using random generator; otherwise, random phase value is 1.

Parameters
rand_phase_val: Input & Ouput value.

Definition at line 457 of file HologramGenerator.cpp.

◆ get_shift_phase_value()

void HologramGenerator::get_shift_phase_value ( Complex shift_phase_val,
int  idx,
ivec2  sig_location 
)
private
Parameters
shift_phase_val: output variable.
idx: the current pixel position.
sig_location: signal location.
See also
encoding_CPU

Definition at line 367 of file HologramGenerator_CPU.cpp.

◆ setMode()

void HologramGenerator::setMode ( bool  isCPU)
  if isCPU_ == true
     CPU implementation
  else
     GPU implementation 
Parameters
isCPU: the value for specifying whether the hologram generation method is implemented on the CPU or GPU

Definition at line 56 of file HologramGenerator.cpp.

Member Data Documentation

◆ alpha_map_

int* HologramGenerator::alpha_map_
private

Definition at line 234 of file HologramGenerator.h.

◆ DEFAULT_DEPTH_QUANTIZATION

uint HologramGenerator::DEFAULT_DEPTH_QUANTIZATION
private

Definition at line 264 of file HologramGenerator.h.

◆ depth_index_

double* HologramGenerator::depth_index_
private

Definition at line 233 of file HologramGenerator.h.

◆ depth_index_gpu_

double* HologramGenerator::depth_index_gpu_
private

Definition at line 229 of file HologramGenerator.h.

◆ DEPTH_PREFIX

std::string HologramGenerator::DEPTH_PREFIX
private

Definition at line 249 of file HologramGenerator.h.

◆ dimg_src_gpu_

unsigned char* HologramGenerator::dimg_src_gpu_
private

Definition at line 228 of file HologramGenerator.h.

◆ dlevel_

std::vector<double> HologramGenerator::dlevel_
private

Definition at line 239 of file HologramGenerator.h.

◆ dlevel_transform_

std::vector<double> HologramGenerator::dlevel_transform_
private

Definition at line 240 of file HologramGenerator.h.

◆ dmap_

double* HologramGenerator::dmap_
private

Definition at line 236 of file HologramGenerator.h.

◆ dmap_src_

double* HologramGenerator::dmap_src_
private

Definition at line 232 of file HologramGenerator.h.

◆ dstep_

double HologramGenerator::dstep_
private

Definition at line 238 of file HologramGenerator.h.

◆ Encoding_Method_

int HologramGenerator::Encoding_Method_
private

Definition at line 259 of file HologramGenerator.h.

◆ eye_center_xy_

vec2 HologramGenerator::eye_center_xy_
private

Definition at line 277 of file HologramGenerator.h.

◆ eye_length_

double HologramGenerator::eye_length_
private

Definition at line 275 of file HologramGenerator.h.

◆ eye_pupil_diameter_

double HologramGenerator::eye_pupil_diameter_
private

Definition at line 276 of file HologramGenerator.h.

◆ f_field_

double HologramGenerator::f_field_
private

Definition at line 274 of file HologramGenerator.h.

◆ FLAG_CHANGE_DEPTH_QUANTIZATION

bool HologramGenerator::FLAG_CHANGE_DEPTH_QUANTIZATION
private

Definition at line 263 of file HologramGenerator.h.

◆ FLAG_STATIC_IMAGE

bool HologramGenerator::FLAG_STATIC_IMAGE
private

Definition at line 252 of file HologramGenerator.h.

◆ focus_distance_

double HologramGenerator::focus_distance_
private

Definition at line 278 of file HologramGenerator.h.

◆ hh_complex_

Complex* HologramGenerator::hh_complex_
private

Definition at line 284 of file HologramGenerator.h.

◆ IMAGE_PREFIX

std::string HologramGenerator::IMAGE_PREFIX
private

Definition at line 248 of file HologramGenerator.h.

◆ img_src_

double* HologramGenerator::img_src_
private

Definition at line 231 of file HologramGenerator.h.

◆ img_src_gpu_

unsigned char* HologramGenerator::img_src_gpu_
private

Definition at line 227 of file HologramGenerator.h.

◆ isCPU_

bool HologramGenerator::isCPU_
private

Definition at line 225 of file HologramGenerator.h.

◆ NUMBER_OF_DEPTH_QUANTIZATION

uint HologramGenerator::NUMBER_OF_DEPTH_QUANTIZATION
private

Definition at line 265 of file HologramGenerator.h.

◆ NUMBER_OF_DIGIT_OF_FRAME_NUMBERING

uint HologramGenerator::NUMBER_OF_DIGIT_OF_FRAME_NUMBERING
private

Definition at line 255 of file HologramGenerator.h.

◆ NUMBER_OF_FRAME

uint HologramGenerator::NUMBER_OF_FRAME
private

Definition at line 254 of file HologramGenerator.h.

◆ params_

HologramParams HologramGenerator::params_
private

Definition at line 245 of file HologramGenerator.h.

◆ Pixel_pitch_xy_

vec2 HologramGenerator::Pixel_pitch_xy_
private

Definition at line 272 of file HologramGenerator.h.

◆ Propagation_Method_

int HologramGenerator::Propagation_Method_
private

Definition at line 258 of file HologramGenerator.h.

◆ RANDOM_PHASE

bool HologramGenerator::RANDOM_PHASE
private

Definition at line 266 of file HologramGenerator.h.

◆ RESULT_FOLDER

std::string HologramGenerator::RESULT_FOLDER
private

Definition at line 250 of file HologramGenerator.h.

◆ RESULT_PREFIX

std::string HologramGenerator::RESULT_PREFIX
private

Definition at line 251 of file HologramGenerator.h.

◆ sim_final_

double* HologramGenerator::sim_final_
private

Definition at line 283 of file HologramGenerator.h.

◆ sim_from_

double HologramGenerator::sim_from_
private

Definition at line 280 of file HologramGenerator.h.

◆ sim_step_num_

int HologramGenerator::sim_step_num_
private

Definition at line 282 of file HologramGenerator.h.

◆ sim_to_

double HologramGenerator::sim_to_
private

Definition at line 281 of file HologramGenerator.h.

◆ sim_type_

int HologramGenerator::sim_type_
private

Definition at line 279 of file HologramGenerator.h.

◆ Simulation_Result_File_Prefix_

std::string HologramGenerator::Simulation_Result_File_Prefix_
private

Definition at line 270 of file HologramGenerator.h.

◆ SLM_pixel_number_xy_

ivec2 HologramGenerator::SLM_pixel_number_xy_
private

Definition at line 273 of file HologramGenerator.h.

◆ SOURCE_FOLDER

std::string HologramGenerator::SOURCE_FOLDER
private

Definition at line 247 of file HologramGenerator.h.

◆ START_OF_FRAME_NUMBERING

uint HologramGenerator::START_OF_FRAME_NUMBERING
private

Definition at line 253 of file HologramGenerator.h.

◆ test_pixel_number_scale_

int HologramGenerator::test_pixel_number_scale_
private

Definition at line 271 of file HologramGenerator.h.

◆ Transform_Method_

int HologramGenerator::Transform_Method_
private

Definition at line 257 of file HologramGenerator.h.

◆ u255_fringe_

double* HologramGenerator::u255_fringe_
private

Definition at line 243 of file HologramGenerator.h.

◆ U_complex_

Complex* HologramGenerator::U_complex_
private

Definition at line 242 of file HologramGenerator.h.

◆ WAVELENGTH

double HologramGenerator::WAVELENGTH
private

Definition at line 261 of file HologramGenerator.h.


The documentation for this class was generated from the following files: