Openholo  v2.1
Open Source Digital Holographic Library
ophDepthMap Class Reference

This class generates CGH based on depth map. More...

#include <ophDepthMap.h>

Inheritance diagram for ophDepthMap:
Collaboration diagram for ophDepthMap:

Public Member Functions

 ophDepthMap ()
 Constructor. More...
 
bool readConfig (const char *fname)
 Read parameters from a config file(config_openholo.txt). More...
 
bool readImageDepth (const char *source_folder, const char *img_prefix, const char *depth_img_prefix)
 Read image and depth map. More...
 
Real generateHologram (void)
 Generate a hologram, main funtion. When the calculation is finished, the angular spectrum is performed. More...
 
virtual void encoding (unsigned int ENCODE_FLAG)
 
virtual void encoding (unsigned int ENCODE_FLAG, unsigned int SSB_PASSBAND)
 
void setViewingWindow (bool is_ViewingWindow)
 Set the value of a variable is_ViewingWindow(true or false) More...
 
ivec2 getRGBImgSize ()
 
ivec2 getDepthImgSize ()
 
void setConfig (OphDepthMapConfig config)
 
void setResolution (ivec2 resolution)
 
uintgetProgress ()
 
void normalize ()
 
void setFieldLens (Real fieldlens)
 
void setNearDepth (Real neardepth)
 
void setFarDepth (Real fardetph)
 
void setNumOfDepth (uint numofdepth)
 
Real getFieldLens (void)
 
Real getNearDepth (void)
 
Real getFarDepth (void)
 
uint getNumOfDepth (void)
 
void getRenderDepth (std::vector< int > &renderdepth)
 
const OphDepthMapConfiggetConfig ()
 
- Public Member Functions inherited from ophGen
 ophGen (void)
 Constructor. More...
 
Real ** getEncodedBuffer (void)
 Function for getting the encoded complex field buffer. More...
 
uchar ** getNormalizedBuffer (void)
 Function for getting the normalized(0~255) complex field buffer. More...
 
void initialize (void)
 Initialize variables for Hologram complex field, encoded data, normalized data. More...
 
int loadPointCloud (const char *pc_file, OphPointCloudData *pc_data_)
 load to point cloud data. More...
 
bool readConfig (const char *fname)
 load to configuration file. More...
 
void AngularSpectrumMethod (Complex< Real > *input, Complex< Real > *output, Real distance, Real k, Real lambda)
 Angular spectrum propagation method. More...
 
void conv_fft2 (Complex< Real > *src1, Complex< Real > *src2, Complex< Real > *dst, ivec2 size)
 Convolution between Complex arrays which have same size. More...
 
void normalize (void)
 Normalization function to save as image file after hologram creation. More...
 
void normalize (int ch)
 
bool save (const char *fname, uint8_t bitsperpixel=8, uchar *src=nullptr, uint px=0, uint py=0)
 Function for saving image files. More...
 
void * load (const char *fname)
 Function for loading image files. More...
 
virtual bool loadAsOhc (const char *fname)
 Function to read OHC file. More...
 
void setPrecision (uint precision)
 Function for setting precision. More...
 
uint getPrecision ()
 
void setEncodeMethod (unsigned int ENCODE_FLAG)
 
void encoding (unsigned int ENCODE_FLAG)
 Encoding Functions. More...
 
void encoding (unsigned int ENCODE_FLAG, Complex< Real > *holo, Real *encoded)
 
void encoding ()
 
virtual void encoding (unsigned int ENCODE_FLAG, unsigned int SSB_PASSBAND, Complex< Real > *holo=nullptr, Real *encoded=nullptr)
 
void encoding (unsigned int BIN_ENCODE_FLAG, unsigned int ENCODE_FLAG, Real threshold, Complex< Real > *holo=nullptr, Real *encoded=nullptr)
 Binary Encoding Functions. More...
 
bool Shift (Real x, Real y)
 
void waveCarry (Real carryingAngleX, Real carryingAngleY, Real distance)
 Wave carry. More...
 
void waveCarry (Complex< Real > *src, Complex< Real > *dst, Real wavelength, int carryIdxX, int carryIdxY)
 
void transVW (int nSize, Real *dst, Real *src)
 
int getStream ()
 
Real getFieldLength ()
 
ivec2 & getEncodeSize (void)
 Function for getting encode size. More...
 
void setResolution (ivec2 resolution)
 Function for setting buffer size. More...
 
Real getElapsedTime ()
 Function for getting elapsed time. More...
 
bool saveRefImages (char *fnameW, char *fnameWC, char *fnameAS, char *fnameSSB, char *fnameHP, char *fnameFreq, char *fnameReal, char *fnameBin, char *fnameReconBin, char *fnameReconErr, char *fnameReconNo)
 
void fresnelPropagation (OphConfig context, Complex< Real > *in, Complex< Real > *out, Real distance)
 Fresnel propagation. More...
 
void fresnelPropagation (Complex< Real > *in, Complex< Real > *out, Real distance, uint channel)
 Fresnel propagation. More...
 
void AngularSpectrumMethod (Complex< Real > *src, Complex< Real > *dst, Real lambda, Real distance)
 
void RS_Diffraction (vec3 src, Complex< Real > *dst, Real lambda, Real distance, Real amplitude)
 
void RS_Diffraction (vec3 src, Complex< Real > *dst, float lambda, float distance, float amplitude)
 
void RS_Diffraction (uchar *src, Complex< Real > *dst, Real lambda, Real distance)
 
void Fresnel_Diffraction (vec3 src, Complex< Real > *dst, Real lambda, Real distance, Real amplitude)
 
void Fresnel_FFT (Complex< Real > *src, Complex< Real > *dst, Real lambda, Real waveRatio, Real distance)
 
bool readImage (const char *fname, bool bRGB)
 
void SetMode (unsigned int mode)
 
unsigned int GetMode ()
 
void SetRandomPhase (bool bRandomPhase)
 
bool GetRandomPhase ()
 
- Public Member Functions inherited from Openholo
 Openholo (void)
 Constructor. More...
 
virtual bool saveAsImg (const char *fname, uint8_t bitsperpixel, uchar *src, int width, int height)
 Function for creating image files. More...
 
virtual ucharloadAsImg (const char *fname)
 Function for loading image files. More...
 
virtual bool saveAsOhc (const char *fname)
 Function to write OHC file
More...
 
Complex< Real > ** getComplexField (void)
 Function for getting the complex field. More...
 
Complex< float > ** getComplexfField (void)
 
OphConfiggetContext (void)
 Function for getting the current context. More...
 
ImageConfiggetImageConfig ()
 Function for getting the image config. More...
 
void setPixelNumber (ivec2 n)
 Function for setting the output resolution. More...
 
void setPixelNumber (int width, int height)
 
void setPixelPitch (vec2 p)
 Function for setting the output pixel pitch. More...
 
void setPixelPitch (Real pitchX, Real pitchY)
 
void setWaveLength (Real w, const uint idx=0)
 Function for setting the wave length. More...
 
void setWaveNum (int nNum)
 
void setImageMerge (bool bMerge)
 
void setImageRotate (bool rotate)
 
void setImageFlip (int flip)
 
bool getImageRotate ()
 
void SetMaxThreadNum (int num)
 
int GetMaxThreadNum ()
 
bool mergeColor (int idx, int width, int height, uchar *src, uchar *dst)
 
bool separateColor (int idx, int width, int height, uchar *src, uchar *dst)
 
- Public Member Functions inherited from Base
 Base (void)
 Constructor. More...
 
unsigned long addRef (void)
 If referenced this(Base's child, not abstract class) instance, must call this method. More...
 
unsigned long release (void)
 Call release() when reference is finished. More...
 

Protected Member Functions

virtual ~ophDepthMap ()
 Destructor. More...
 
void free_gpu (void)
 
void ophFree (void)
 Pure virtual function for override in child classes. More...
 
- Protected Member Functions inherited from ophGen
virtual ~ophGen (void)=0
 Destructor. More...
 
bool save (const char *fname, uint8_t bitsperpixel, uint px, uint py, uint fnum, uchar *args ...)
 Called when saving multiple hologram data at a time. More...
 
void resetBuffer ()
 reset buffer More...
 
template<typename T >
void RealPart (Complex< T > *holo, T *encoded, const int size)
 Encoding method. More...
 
template<typename T >
void ImaginearyPart (Complex< T > *holo, T *encoded, const int size)
 
template<typename T >
void Phase (Complex< T > *holo, T *encoded, const int size)
 
template<typename T >
void Amplitude (Complex< T > *holo, T *encoded, const int size)
 
template<typename T >
void TwoPhase (Complex< T > *holo, T *encoded, const int size)
 
template<typename T >
void Burckhardt (Complex< T > *holo, T *encoded, const int size)
 
template<typename T >
void SimpleNI (Complex< T > *holo, T *encoded, const int size)
 
void singleSideBand (Complex< Real > *holo, Real *encoded, const ivec2 holosize, int passband)
 Encoding method. More...
 
void freqShift (Complex< Real > *src, Complex< Real > *dst, const ivec2 holosize, int shift_x, int shift_y)
 Frequency shift. More...
 
bool binaryErrorDiffusion (Complex< Real > *holo, Real *encoded, const ivec2 holosize, const int type, Real threshold)
 
bool getWeightED (const ivec2 holosize, const int type, ivec2 *pNw)
 
bool shiftW (ivec2 holosize)
 
void binarization (Complex< Real > *src, Real *dst, const int size, int ENCODE_FLAG, Real threshold)
 
void CorrectionChromaticAberration (uchar *src, uchar *dst, int width, int height, int ch)
 
void encodeSideBand (bool bCPU, ivec2 sig_location)
 Encode the CGH according to a signal location parameter. More...
 
void encodeSideBand_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 encodeSideBand_GPU (int cropx1, int cropx2, int cropy1, int cropy2, ivec2 sig_location)
 Encode the CGH according to a signal location parameter on the GPU. More...
 
void getShiftPhaseValue (Complex< Real > &shift_phase_val, int idx, ivec2 sig_location)
 Calculate the shift phase value. More...
 
void GetRandomPhaseValue (Complex< Real > &rand_phase_val, bool rand_phase)
 Assign random phase value if random_phase == 1. More...
 
void ScaleChange (Real *src, Real *dst, int nSize, Real scaleX, Real scaleY, Real scaleZ)
 
void GetMaxMin (Real *src, int len, Real &max, Real &min)
 
- Protected Member Functions inherited from Openholo
virtual ~Openholo (void)=0
 Destructor. More...
 
bool checkExtension (const char *fname, const char *ext)
 Functions for extension checking. More...
 
bool loadAsImgUpSideDown (const char *fname, uchar *dst)
 Function for loading image files | Output image data upside down. More...
 
bool getImgSize (int &w, int &h, int &bytesperpixel, const char *fname)
 Function for getting the image size. More...
 
void imgScaleBilinear (uchar *src, uchar *dst, int w, int h, int neww, int newh, int channels=1)
 Function for change image size. More...
 
void convertToFormatGray8 (uchar *src, uchar *dst, int w, int h, int bytesperpixel)
 Function for convert image format to gray8. More...
 
void fft1 (int n, Complex< Real > *in, int sign=OPH_FORWARD, uint flag=OPH_ESTIMATE)
 Functions for performing fftw 1-dimension operations inside Openholo. More...
 
void fft2 (ivec2 n, Complex< Real > *in, int sign=OPH_FORWARD, uint flag=OPH_ESTIMATE)
 Functions for performing fftw 2-dimension operations inside Openholo. More...
 
void fft3 (ivec3 n, Complex< Real > *in, int sign=OPH_FORWARD, uint flag=OPH_ESTIMATE)
 Functions for performing fftw 3-dimension operations inside Openholo. More...
 
void fftExecute (Complex< Real > *out, bool bReverse=false)
 Execution functions to be called after fft1, fft2, and fft3. More...
 
void fftFree (void)
 
void fftInit2D (ivec2 size, int sign, unsigned int flag)
 
void fft2 (Complex< Real > *src, Complex< Real > *dst, int nx, int ny, int type, bool bNormalized=false)
 Convert data from the spatial domain to the frequency domain using 2D FFT on CPU. More...
 
void fftShift (int nx, int ny, Complex< Real > *input, Complex< Real > *output)
 Swap the top-left quadrant of data with the bottom-right , and the top-right quadrant with the bottom-left. More...
 
void fftShift (int nx, int ny, Complex< Real > *input, fftw_complex *output)
 
void fftShift (int nx, int ny, fftw_complex *input, Complex< Real > *output)
 
void setPixelNumberOHC (const ivec2 pixel_number)
 getter/setter for OHC file read and write More...
 
void setPixelPitchOHC (const vec2 pixel_pitch)
 
void setWavelengthOHC (const Real wavelength, const LenUnit wavelength_unit)
 
void setWaveLengthNumOHC (const uint wavelength_num)
 
void setColorTypeOHC (const ColorType color_type)
 
void setColorArrangeOHC (const ColorArran color_arrange)
 
void setWaveLengthUnitOHC (const LenUnit length_unit)
 
void setFieldEncodingOHC (const FldStore field_store, const FldCodeType field_code_type)
 
void setPhaseEncodingOHC (const BPhaseCode phase_code, const vec2 phase_code_range)
 
void addWaveLengthNComplexFieldDataOHC (const Real wavelength, const OphComplexField &complex_field)
 Function to add ComplexField when adding wavelength data. More...
 
void addWaveLengthOHC (const Real wavelength)
 
void addComplexFieldDataOHC (const OphComplexField &complex_field)
 
void getPixelNumberOHC (ivec2 &pixel_number)
 
void getPixelPitchOHC (vec2 &pixel_pitch)
 
void getWavelengthOHC (vector< Real > &wavelength)
 
void getWaveLengthNumOHC (uint &wavelength_num)
 
void getColorTypeOHC (ColorType &color_type)
 
void getColorArrangeOHC (ColorArran &color_arrange)
 
void getWaveLengthUnitOHC (LenUnit &length_unit)
 
void getComplexFieldDataOHC (Complex< Real > **cmplx, uint wavelen_idx)
 
void getComplexFieldDataOHC (OphComplexField &cmplx, uint wavelen_idx)
 
- Protected Member Functions inherited from Base
virtual ~Base (void)
 Destructor. More...
 

Additional Inherited Members

- Public Types inherited from ophGen
enum  PRECISION { SINGLE, DOUBLE }
 
enum  ENCODE_FLAG {
  ENCODE_PHASE, ENCODE_AMPLITUDE, ENCODE_REAL, ENCODE_IMAGINEARY,
  ENCODE_SIMPLENI, ENCODE_BURCKHARDT, ENCODE_TWOPHASE, ENCODE_SSB,
  ENCODE_OFFSSB, ENCODE_SIMPLEBINARY, ENCODE_EDBINARY
}
 
enum  SSB_PASSBAND { SSB_LEFT, SSB_RIGHT, SSB_TOP, SSB_BOTTOM }
 
enum  ED_WType { FLOYD_STEINBERG, SINGLE_RIGHT, SINGLE_DOWN, ITERATIVE_DESIGN }
 
- Public Attributes inherited from ophGen
ucharimgRGB
 
ucharimgDepth
 
int m_width
 
int m_height
 
int m_bpp
 
- Protected Attributes inherited from ophGen
ivec2 m_vecEncodeSize
 Encoded hologram size, varied from encoding type. More...
 
int ENCODE_METHOD
 Encoding method flag. More...
 
int SSB_PASSBAND
 Passband in Single-side band encoding. More...
 
Real m_elapsedTime
 Elapsed time of generate hologram. More...
 
Real ** m_lpEncoded
 buffer to encoded. More...
 
uchar ** m_lpNormalized
 buffer to normalized. More...
 
Real m_dFieldLength
 
int m_nStream
 
Complex< Real > * src1FT
 buffer to conv_fft2 More...
 
Complex< Real > * src2FT
 
Complex< Real > * dstFT
 
int ss
 Binary Encoding - Error diffusion. More...
 
Complex< Real > * AS
 
Complex< Real > * normalized
 
Complex< Real > * fftTemp
 
Realweight
 
Complex< Real > * weightC
 
Complex< Real > * freqW
 
RealrealEnc
 
Realbinary
 
RealmaskSSB
 
RealmaskHP
 
unsigned int m_mode
 
bool m_bRandomPhase
 
- Protected Attributes inherited from Openholo
OphConfig context_
 
ImageConfig imgCfg
 
Complex< Real > ** complex_H
 
Complex< float > ** complexf_H
 
ImgEncoderOhcOHC_encoder
 OHC file format Variables for read and write. More...
 
ImgDecoderOhcOHC_decoder
 
- Protected Attributes inherited from Base
unsigned long refCnt
 

Detailed Description

This class generates CGH based on depth map.

Author

Definition at line 110 of file ophDepthMap.h.

Constructor & Destructor Documentation

◆ ophDepthMap()

ophDepthMap::ophDepthMap ( )
explicit

Constructor.

Initialize variables.

Definition at line 59 of file ophDepthMap.cpp.

◆ ~ophDepthMap()

ophDepthMap::~ophDepthMap ( )
protectedvirtual

Destructor.

Definition at line 84 of file ophDepthMap.cpp.

Member Function Documentation

◆ encoding() [1/2]

void ophDepthMap::encoding ( unsigned int  ENCODE_FLAG)
virtual

Definition at line 364 of file ophDepthMap.cpp.

◆ encoding() [2/2]

void ophDepthMap::encoding ( unsigned int  ENCODE_FLAG,
unsigned int  SSB_PASSBAND 
)
virtual

Definition at line 382 of file ophDepthMap.cpp.

◆ free_gpu()

void ophDepthMap::free_gpu ( void  )
protected

Definition at line 209 of file ophDepthMap_GPU.cpp.

◆ generateHologram()

Real ophDepthMap::generateHologram ( void  )

Generate a hologram, main funtion. When the calculation is finished, the angular spectrum is performed.

Returns
implement time (sec)

Definition at line 325 of file ophDepthMap.cpp.

◆ getConfig()

const OphDepthMapConfig& ophDepthMap::getConfig ( )
inline

Definition at line 167 of file ophDepthMap.h.

◆ getDepthImgSize()

ivec2 ophDepthMap::getDepthImgSize ( )
inline

Definition at line 144 of file ophDepthMap.h.

◆ getFarDepth()

Real ophDepthMap::getFarDepth ( void  )
inline

Definition at line 163 of file ophDepthMap.h.

◆ getFieldLens()

Real ophDepthMap::getFieldLens ( void  )
inline

Definition at line 161 of file ophDepthMap.h.

◆ getNearDepth()

Real ophDepthMap::getNearDepth ( void  )
inline

Definition at line 162 of file ophDepthMap.h.

◆ getNumOfDepth()

uint ophDepthMap::getNumOfDepth ( void  )
inline

Definition at line 164 of file ophDepthMap.h.

◆ getProgress()

uint* ophDepthMap::getProgress ( )
inline

Definition at line 150 of file ophDepthMap.h.

◆ getRenderDepth()

void ophDepthMap::getRenderDepth ( std::vector< int > &  renderdepth)
inline

Definition at line 165 of file ophDepthMap.h.

◆ getRGBImgSize()

ivec2 ophDepthMap::getRGBImgSize ( )
inline

Definition at line 143 of file ophDepthMap.h.

◆ normalize()

void ophDepthMap::normalize ( void  )

Definition at line 712 of file ophDepthMap.cpp.

◆ ophFree()

void ophDepthMap::ophFree ( void  )
protectedvirtual

Pure virtual function for override in child classes.

Reimplemented from ophGen.

Definition at line 686 of file ophDepthMap.cpp.

◆ readConfig()

bool ophDepthMap::readConfig ( const char *  fname)

Read parameters from a config file(config_openholo.txt).

Returns
true if config infomation are sucessfully read, flase otherwise.

Definition at line 96 of file ophDepthMap.cpp.

◆ readImageDepth()

bool ophDepthMap::readImageDepth ( const char *  source_folder,
const char *  img_prefix,
const char *  depth_img_prefix 
)

Read image and depth map.

Read input files and load image & depth map data. If the input image size is different with the dislay resolution, resize the image size.

Parameters
ftr: the frame number of the image.
Returns
true if image data are sucessfully read, flase otherwise.
See also
prepare_inputdata_CPU, prepare_inputdata_GPU

Definition at line 196 of file ophDepthMap.cpp.

◆ setConfig()

void ophDepthMap::setConfig ( OphDepthMapConfig  config)
inline

Definition at line 146 of file ophDepthMap.h.

◆ setFarDepth()

void ophDepthMap::setFarDepth ( Real  fardetph)
inline

Definition at line 158 of file ophDepthMap.h.

◆ setFieldLens()

void ophDepthMap::setFieldLens ( Real  fieldlens)
inline

Definition at line 156 of file ophDepthMap.h.

◆ setNearDepth()

void ophDepthMap::setNearDepth ( Real  neardepth)
inline

Definition at line 157 of file ophDepthMap.h.

◆ setNumOfDepth()

void ophDepthMap::setNumOfDepth ( uint  numofdepth)
inline

Definition at line 159 of file ophDepthMap.h.

◆ setResolution()

void ophDepthMap::setResolution ( ivec2  resolution)

Definition at line 702 of file ophDepthMap.cpp.

◆ setViewingWindow()

void ophDepthMap::setViewingWindow ( bool  is_ViewingWindow)

Set the value of a variable is_ViewingWindow(true or false)

if is_ViewingWindow == true
Transform viewing window
else
Hologram 
Parameters
is_ViewingWindow: the value for specifying whether the hologram generation method is implemented on the viewing window

Definition at line 88 of file ophDepthMap.cpp.


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