Openholo  v1.0
Open Source Digital Holographic Library
ophSig Class Reference

#include <ophSig.h>

Inheritance diagram for ophSig:
Collaboration diagram for ophSig:

Public Member Functions

 ophSig (void)
 Constructor. More...
 
bool load (const char *real, const char *imag)
 Load bmp or bin file. More...
 
bool save (const char *real, const char *imag)
 Save data as bmp or bin file. More...
 
bool save (const char *real)
 
bool loadAsOhc (const char *fname)
 Function to read OHC file. More...
 
bool saveAsOhc (const char *fname)
 Function to write OHC file
More...
 
template<typename T >
void linInterp (vector< T > &X, matrix< Complex< T >> &src, vector< T > &Xq, matrix< Complex< T >> &dst)
 
template<typename T >
vector< T > linspace (T first, T last, int len)
 Generate linearly spaced vector. More...
 
template<typename T >
void absMat (matrix< Complex< T >> &src, matrix< T > &dst)
 Function for Linear interpolation 1D. More...
 
template<typename T >
void absMat (matrix< T > &src, matrix< T > &dst)
 Function for extracts real absolute value. More...
 
template<typename T >
void angleMat (matrix< Complex< T >> &src, matrix< T > &dst)
 Function for extracts Complex phase value. More...
 
template<typename T >
void conjMat (matrix< Complex< T >> &src, matrix< Complex< T >> &dst)
 Function for extracts Complex conjugate value. More...
 
template<typename T >
void expMat (matrix< Complex< T >> &src, matrix< Complex< T >> &dst)
 Function for returns exponent ex. More...
 
template<typename T >
void expMat (matrix< T > &src, matrix< T > &dst)
 Function for returns exponent e(x), where x is complex number. More...
 
template<typename T >
void meanOfMat (matrix< T > &src, T &dst)
 Function for returns exponent e(x), where x is real number. More...
 
Real maxOfMat (matrix< Real > &src)
 Function for extracts max of matrix. More...
 
Complex< RealmaxOfMat (matrix< Complex< Real >> &src)
 
Real minOfMat (matrix< Real > &src)
 Function for extracts min of matrix. More...
 
Complex< RealminOfMat (matrix< Complex< Real >> &src)
 
template<typename T >
void normalizeMat (matrix< T > &src, matrix< T > &dst)
 
void fftShift (matrix< Complex< Real >> &src, matrix< Complex< Real >> &dst)
 
template<typename T >
void fft1 (matrix< Complex< T >> &src, matrix< Complex< T >> &dst, int sign=OPH_FORWARD, uint flag=OPH_ESTIMATE)
 
template<typename T >
void fft2 (matrix< Complex< T >> &src, matrix< Complex< T >> &dst, int sign=OPH_FORWARD, uint flag=OPH_ESTIMATE)
 Function for Fast Fourier transform 2D. More...
 
bool readConfig (const char *fname)
 Function for Read parameter. More...
 
bool sigConvertOffaxis (Real angleX, Real angleY)
 Function for Convert complex hologram to off-axis hologram. More...
 
bool cvtOffaxis_CPU (Real angleX, Real angleY)
 
void cvtOffaxis_GPU (Real angleX, Real angleY)
 
bool sigConvertHPO (Real depth, Real_t redRate)
 Function for convert complex hologram to horizontal parallax only hologram. More...
 
bool sigConvertHPO_CPU (Real depth, Real_t redRate)
 
bool sigConvertHPO_GPU (Real depth, Real_t redRate)
 
bool sigConvertCAC (double red, double green, double blue)
 Function for Chromatic aberration compensation filter. More...
 
bool sigConvertCAC_CPU (double red, double green, double blue)
 
bool sigConvertCAC_GPU (double red, double green, double blue)
 
bool propagationHolo (float depth)
 Function for Chromatic aberration compensation filter. More...
 
bool propagationHolo_CPU (float depth)
 
bool propagationHolo_GPU (float depth)
 
OphComplexField propagationHolo (OphComplexField complexH, float depth)
 Function for propagation hologram. More...
 
double sigGetParamAT ()
 Extraction of distance parameter using axis transfomation. More...
 
double sigGetParamAT_CPU ()
 
double sigGetParamAT_GPU ()
 
double sigGetParamSF (float zMax, float zMin, int sampN, float th)
 Extraction of distance parameter using sharpness functions. More...
 
double sigGetParamSF_CPU (float zMax, float zMin, int sampN, float th)
 
double sigGetParamSF_GPU (float zMax, float zMin, int sampN, float th)
 
bool getComplexHFromPSDH (const char *fname0, const char *fname90, const char *fname180, const char *fname270)
 Extraction of complex field from 4 phase shifted interference patterns. More...
 
void setMode (bool is_CPU)
 
void cField2Buffer (matrix< Complex< Real >> &src, Complex< Real > **dst, int nx, int ny)
 
void ColorField2Buffer (matrix< Complex< Real >> &src, Complex< Real > **dst, int nx, int ny)
 
- 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...
 
Complex< Real > ** getComplexField (void)
 Function for getting the complex field. More...
 
OphConfiggetContext (void)
 Function for getting the current context. More...
 
void setPixelNumber (ivec2 n)
 Function for setting the output resolution. More...
 
void setPixelPitch (vec2 p)
 Function for setting the output pixel pitch. More...
 
void setWaveLength (Real w, const uint idx)
 Function for setting the wave length. More...
 
- 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 ~ophSig (void)=default
 
virtual void ophFree (void)
 Pure virtual function for override in child classes. More...
 
- 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 imgScaleBilnear (uchar *src, uchar *dst, int w, int h, int neww, int newh)
 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)
 Execution functions to be called after fft1, fft2, and fft3. More...
 
void fftFree (void)
 
void fftwShift (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 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...
 

Protected Attributes

bool is_CPU
 
ophSigConfig _cfgSig
 
OphComplexFieldComplexH
 
fftw_plan bwd_plan
 
fftw_plan fwd_plan
 
int _wavelength_num
 
Real_t _radius
 
Real_t_foc
 
- Protected Attributes inherited from Openholo
OphConfig context_
 
Complex< Real > ** complex_H
 
ImgEncoderOhcOHC_encoder
 OHC file format Variables for read and write. More...
 
ImgDecoderOhcOHC_decoder
 
- Protected Attributes inherited from Base
unsigned long refCnt
 

Detailed Description

Author

Definition at line 100 of file ophSig.h.

Constructor & Destructor Documentation

◆ ~ophSig()

virtual ophSig::~ophSig ( void  )
protectedvirtualdefault

◆ ophSig()

ophSig::ophSig ( void  )
explicit

Constructor.

Definition at line 50 of file ophSig.cpp.

Member Function Documentation

◆ absMat() [1/2]

template<typename T >
void ophSig::absMat ( matrix< Complex< T >> &  src,
matrix< T > &  dst 
)
inline

Function for Linear interpolation 1D.

Parameters
Xinput signal coordinate
ininput signal
Xqoutput signal coordinate
outoutput signal Function for extracts Complex magnitude value
srcinput signal
dstoutput signal

Definition at line 181 of file ophSig.h.

◆ absMat() [2/2]

template<typename T >
void ophSig::absMat ( matrix< T > &  src,
matrix< T > &  dst 
)
inline

Function for extracts real absolute value.

Parameters
srcinput signal
dstoutput signal

Definition at line 199 of file ophSig.h.

◆ angleMat()

template<typename T >
void ophSig::angleMat ( matrix< Complex< T >> &  src,
matrix< T > &  dst 
)
inline

Function for extracts Complex phase value.

Parameters
srcinput signal
dstoutput signal

Definition at line 217 of file ophSig.h.

◆ cField2Buffer()

void ophSig::cField2Buffer ( matrix< Complex< Real >> &  src,
Complex< Real > **  dst,
int  nx,
int  ny 
)

Definition at line 58 of file ophSig.cpp.

◆ ColorField2Buffer()

void ophSig::ColorField2Buffer ( matrix< Complex< Real >> &  src,
Complex< Real > **  dst,
int  nx,
int  ny 
)

Definition at line 73 of file ophSig.cpp.

◆ conjMat()

template<typename T >
void ophSig::conjMat ( matrix< Complex< T >> &  src,
matrix< Complex< T >> &  dst 
)
inline

Function for extracts Complex conjugate value.

Parameters
srcinput signal
dstoutput signal

Definition at line 235 of file ophSig.h.

◆ cvtOffaxis_CPU()

bool ophSig::cvtOffaxis_CPU ( Real  angleX,
Real  angleY 
)

Definition at line 861 of file ophSig.cpp.

◆ cvtOffaxis_GPU()

void ophSig::cvtOffaxis_GPU ( Real  angleX,
Real  angleY 
)

Definition at line 64 of file ophSig_GPU.cpp.

◆ expMat() [1/2]

template<typename T >
void ophSig::expMat ( matrix< Complex< T >> &  src,
matrix< Complex< T >> &  dst 
)
inline

Function for returns exponent ex.

Parameters
srcinput signal
dstoutput signal

Definition at line 254 of file ophSig.h.

◆ expMat() [2/2]

template<typename T >
void ophSig::expMat ( matrix< T > &  src,
matrix< T > &  dst 
)
inline

Function for returns exponent e(x), where x is complex number.

Parameters
srcinput signal
dstoutput signal

Definition at line 273 of file ophSig.h.

◆ fft1()

template<typename T >
void ophSig::fft1 ( matrix< Complex< T >> &  src,
matrix< Complex< T >> &  dst,
int  sign = OPH_FORWARD,
uint  flag = OPH_ESTIMATE 
)

Definition at line 115 of file ophSig.cpp.

◆ fft2()

template<typename T >
void ophSig::fft2 ( matrix< Complex< T >> &  src,
matrix< Complex< T >> &  dst,
int  sign = OPH_FORWARD,
uint  flag = OPH_ESTIMATE 
)

Function for Fast Fourier transform 2D.

Parameters
srcinput signal
dstoutput signal
signsign = OPH_FORWARD is fft and sign= OPH_BACKWARD is inverse fft
flagflag = OPH_ESTIMATE is fine best way to compute the transform but it is need some time, flag = OPH_ESTIMATE is probably sub-optimal

Definition at line 151 of file ophSig.cpp.

◆ fftShift()

void ophSig::fftShift ( matrix< Complex< Real >> &  src,
matrix< Complex< Real >> &  dst 
)
inline

Definition at line 396 of file ophSig.h.

◆ linInterp()

template<typename T >
void ophSig::linInterp ( vector< T > &  X,
matrix< Complex< T >> &  src,
vector< T > &  Xq,
matrix< Complex< T >> &  dst 
)

Definition at line 92 of file ophSig.cpp.

◆ linspace()

template<typename T >
vector<T> ophSig::linspace ( first,
last,
int  len 
)
inline

Generate linearly spaced vector.

Parameters
firstfirst number of vector
lastlast number of vector
lenvector with specified number of values
Returns
result vector

Definition at line 160 of file ophSig.h.

◆ load()

bool ophSig::load ( const char *  real,
const char *  imag 
)

Load bmp or bin file.

Parameters
realreal data file name
imagimag data file name
bitpixelbit per pixel
Returns
if works well return 0 or error occurs return -1

Definition at line 257 of file ophSig.cpp.

◆ loadAsOhc()

bool ophSig::loadAsOhc ( const char *  fname)
virtual

Function to read OHC file.

Parameters
[in]fnameFile name
Returns
Type: bool
If the succeeds to load OHC file, the return value is true.
If the fails to load OHC file, the return value is false.

Reimplemented from Openholo.

Definition at line 200 of file ophSig.cpp.

◆ maxOfMat() [1/2]

Real ophSig::maxOfMat ( matrix< Real > &  src)
inline

Function for extracts max of matrix.

Parameters
srcinput signal

Definition at line 307 of file ophSig.h.

◆ maxOfMat() [2/2]

Complex<Real> ophSig::maxOfMat ( matrix< Complex< Real >> &  src)
inline

Definition at line 320 of file ophSig.h.

◆ meanOfMat()

template<typename T >
void ophSig::meanOfMat ( matrix< T > &  src,
T &  dst 
)
inline

Function for returns exponent e(x), where x is real number.

Parameters
srcinput signal
dstoutput signal

Definition at line 291 of file ophSig.h.

◆ minOfMat() [1/2]

Real ophSig::minOfMat ( matrix< Real > &  src)
inline

Function for extracts min of matrix.

Parameters
srcinput signal

Definition at line 336 of file ophSig.h.

◆ minOfMat() [2/2]

Complex<Real> ophSig::minOfMat ( matrix< Complex< Real >> &  src)
inline

Definition at line 348 of file ophSig.h.

◆ normalizeMat()

template<typename T >
void ophSig::normalizeMat ( matrix< T > &  src,
matrix< T > &  dst 
)
inline

Definition at line 378 of file ophSig.h.

◆ ophFree()

void ophSig::ophFree ( void  )
protectedvirtual

Pure virtual function for override in child classes.

Reimplemented from Openholo.

Definition at line 1452 of file ophSig.cpp.

◆ propagationHolo() [1/2]

bool ophSig::propagationHolo ( float  depth)

Function for Chromatic aberration compensation filter.

Returns
if works well return 0 or error occurs return -1

Definition at line 821 of file ophSig.cpp.

◆ propagationHolo() [2/2]

OphComplexField ophSig::propagationHolo ( OphComplexField  complexH,
float  depth 
)

Function for propagation hologram.

Parameters
depthposition from hologram plane to propagation hologram plane
Returns
output signal

Definition at line 1083 of file ophSig.cpp.

◆ propagationHolo_CPU()

bool ophSig::propagationHolo_CPU ( float  depth)

Definition at line 1042 of file ophSig.cpp.

◆ propagationHolo_GPU()

bool ophSig::propagationHolo_GPU ( float  depth)

Definition at line 257 of file ophSig_GPU.cpp.

◆ readConfig()

bool ophSig::readConfig ( const char *  fname)

Function for Read parameter.

Parameters
fnamefile name
Returns
if works well return 0 or error occurs return -1

Definition at line 999 of file ophSig.cpp.

◆ save() [1/2]

bool ophSig::save ( const char *  real,
const char *  imag 
)

Save data as bmp or bin file.

Parameters
realreal data file name
imagimag data file name
bitpixelbit per pixel
Returns
if works well return 0 or error occurs return -1

Definition at line 385 of file ophSig.cpp.

◆ save() [2/2]

bool ophSig::save ( const char *  real)

Definition at line 676 of file ophSig.cpp.

◆ saveAsOhc()

bool ophSig::saveAsOhc ( const char *  fname)
virtual

Function to write OHC file

Parameters
[in]fnameFile name
Returns
Type: bool
If the succeeds to save OHC file, the return value is true.
If the fails to save OHC file, the return value is false.

Reimplemented from Openholo.

Definition at line 229 of file ophSig.cpp.

◆ setMode()

void ophSig::setMode ( bool  is_CPU)

Definition at line 86 of file ophSig.cpp.

◆ sigConvertCAC_CPU()

bool ophSig::sigConvertCAC_CPU ( double  red,
double  green,
double  blue 
)

Definition at line 951 of file ophSig.cpp.

◆ sigConvertCAC_GPU()

bool ophSig::sigConvertCAC_GPU ( double  red,
double  green,
double  blue 
)

Definition at line 185 of file ophSig_GPU.cpp.

◆ sigConvertHPO_CPU()

bool ophSig::sigConvertHPO_CPU ( Real  depth,
Real_t  redRate 
)

Definition at line 905 of file ophSig.cpp.

◆ sigConvertHPO_GPU()

bool ophSig::sigConvertHPO_GPU ( Real  depth,
Real_t  redRate 
)

Definition at line 118 of file ophSig_GPU.cpp.

◆ sigGetParamAT_CPU()

double ophSig::sigGetParamAT_CPU ( )

Definition at line 1143 of file ophSig.cpp.

◆ sigGetParamAT_GPU()

double ophSig::sigGetParamAT_GPU ( )

Definition at line 377 of file ophSig_GPU.cpp.

◆ sigGetParamSF_CPU()

double ophSig::sigGetParamSF_CPU ( float  zMax,
float  zMin,
int  sampN,
float  th 
)

Definition at line 1240 of file ophSig.cpp.

◆ sigGetParamSF_GPU()

double ophSig::sigGetParamSF_GPU ( float  zMax,
float  zMin,
int  sampN,
float  th 
)

Definition at line 314 of file ophSig_GPU.cpp.

Member Data Documentation

◆ _cfgSig

ophSigConfig ophSig::_cfgSig
protected

Definition at line 108 of file ophSig.h.

◆ _foc

Real_t* ophSig::_foc
protected

Definition at line 124 of file ophSig.h.

◆ _radius

Real_t ophSig::_radius
protected

Definition at line 123 of file ophSig.h.

◆ _wavelength_num

int ophSig::_wavelength_num
protected

Definition at line 118 of file ophSig.h.

◆ bwd_plan

fftw_plan ophSig::bwd_plan
protected

Definition at line 110 of file ophSig.h.

◆ ComplexH

OphComplexField* ophSig::ComplexH
protected

Definition at line 109 of file ophSig.h.

◆ fwd_plan

fftw_plan ophSig::fwd_plan
protected

Definition at line 110 of file ophSig.h.

◆ is_CPU

bool ophSig::is_CPU
protected

Definition at line 107 of file ophSig.h.


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