WPOCT Software Developer's Kit (SDK)
SDK For using Wasatch Photonics OCT Spectrometers
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
WPScanConverter Class Reference

Class that converts a scanned image from one format to another. More...

#include <WPScanConverter.h>

Inheritance diagram for WPScanConverter:
Inheritance graph
[legend]
Collaboration diagram for WPScanConverter:
Collaboration graph
[legend]

Public Member Functions

const char * GetQualifiedInputFileName () const override
 Get the fully qualified file name (includes path).
 
const char * GetOutputIntensityName () const override
 Get the intensity file name (no path).
 
const char * GetOutputPhaseName () const override
 Get the phase file name (no path).
 
const char * GetOutputDirectory () const override
 Get the output directory.
 
const char * GetCalibrationFringeFile () const override
 Get the calibration fringe file name.
 
bool GetOutputIntensity () const override
 Get the flag that determines if intensity is output.
 
bool GetOutputPhase () const override
 Get the flag that determines if phase is output.
 
bool GetDeleteInputFileAfterConversion () const override
 Get the flag that determines if the RAW input file is deleted after data is converted.
 
bool GetOutputTiffFormat () const override
 Get the flag that determines if the output files will be in Tiff format.
 
bool GetOutputLogOfData () const override
 Get the flag that determines if the log of the output data is taken/used.
 
bool GetUseContrast () const override
 Get the flag that determines if contrast is used on the output.
 
bool GetUseScaling () const override
 Get the flag that determines if scaling is used on the output.
 
int GetAScansPerBScan () const override
 Get the number of A-scans in a B-scan.
 
int GetAScanSize () const override
 Get the size of an A-scan.
 
bool GetScanDimensions (int *width, int *height) const override
 Get the width and height of a scan.
 
bool GetDispersionCoefficients (float *coefficients, int length) const override
 Get the dispersion coefficients.
 
bool GetNumberOfLinesToIgnore (int *top, int *bottom) const override
 Get the top and bottom number of lines to ignore.
 
bool GetMinMaxScaling (float *min, float *max) const override
 Get the min and max scaling values.
 
int GetNumScanProcessors () const override
 Get the number of scan processors currently in use.
 
int GetAScanAverage () const override
 Get the number of A-scan averages.
 
virtual bool GetUseMovingAverage () const override
 Getters for displaying a moving average.
 
virtual int GetMovingAverageWindowSize () const override
 Gets the window size of the moving average. More...
 
bool SetQualifiedInputFileName (const char *name) override
 Set the fully qualified file name (includes path).
 
bool SetOutputIntensityName (const char *name) override
 Set the intensity file name (no path).
 
bool SetOutputPhaseName (const char *name) override
 Set the phase file name (no path).
 
bool SetOutputDirectory (const char *name) override
 Set the output directory, including drive letter.
 
bool SetCalibrationFringeFile (const char *name) override
 Set the calibration fringe file name.
 
bool SetOutputIntensity (bool value) override
 Set the flag that determines if intensity is output.
 
bool SetOutputPhase (bool value) override
 Set the flag that determines if phase is output.
 
bool SetDeleteInputFileAfterConversion (bool value) override
 Set the flag that determines if the RAW input file is deleted after data is converted.
 
bool SetOutputTiffFormat (bool value) override
 Get the flag that determines if the output files will be in Tiff format.
 
bool SetOutputLogOfData (bool value) override
 Set the flag that determines if the log of the output data is taken/used.
 
bool SetUseScaling (bool value) override
 Set the flag that determines if scaling is used on the output. More...
 
bool SetUseContrast (bool value) override
 Set the flag that determines if contrast is used on the output.
 
bool SetDispersionCoefficients (const float *dispersionCoeffients, int length) override
 Set the dispersion coefficients.
 
bool SetDispersionOptimizationParameters (int numCoefficients, int maxIterations, float *initialGuesses, int startLine, int stopLine, int offset) override
 Set the values that are used to calculate the optimal dispersion coefficients. More...
 
bool CalcDispersionCoefficients (const unsigned short *inData, int width, int height, float *coefficients) override
 Calc the optimal dispersion coefficients. More...
 
bool SetNumberOfLinesToIgnore (int top, int bottom) override
 Set the top and bottom number of lines to ignore.
 
bool SetMinMaxScaling (float min, float max) override
 Set the min and max scaling values.
 
bool SetAScansPerBScan (int value) override
 Get the number of A-scans in a B-scan.
 
bool SetAScanSize (int value) override
 Set the size of an A-scan.
 
bool SetScanDimensions (int aScansPerBScan, int aScanSize) override
 Set the width and height of a scan.
 
bool SetAScanAverage (int value) override
 Set the A-scan average. Returns true if successful.
 
bool SetNumScanProcessors (int value) override
 Set the number of scan processors currently in use.
 
bool SetUseMovingAverage (bool value) override
 Setters for displaying a moving average.
 
bool SetMovingAverageWindowSize (int value) override
 Sets the window size of the moving average. More...
 
bool ResetMovingAverage () override
 Resets the moving average by clearing the buffers. More...
 
bool UpdateBackgroundImage () override
 Update the background image used for background subtraction the next time a conversion is performed. More...
 
bool GetBackgroundImage (float *buffer, int size) override
 Get the current background image.
 
bool SetBackgroundImage (float *buffer, int size) override
 Set the current background image.
 
bool ConvertSpectralDataToIntensity (IWPOCTInOutData *inOutData) override
 Convert raw spectral data to intensity array. More...
 
bool ConvertSpectralDataToIntensity (const unsigned short *inData, float *outIntensity) override
 Convert raw spectral data to intensity array. More...
 
bool ConvertSpectralDataToPhaseIntensity (IWPOCTInOutData *inOutData) override
 Convert float array to phase and intensity. Returns true if successful.
 
bool ConvertSpectralDataToPhaseIntensity (const unsigned short *inData, float *outIntensity, float *outPhase) override
 Convert float array to phase and intensity. Returns true if successful.
 
bool ConvertSpectralFileToPhaseIntensity () override
 Convert raw spectral data file to phase and intensity files. More...
 
bool ConvertSpectralFileToPhaseIntensity (const char *qualifiedFileName) override
 Convert binary file to phase and intensity files. More...
 
bool ConvertSpectralDirToPhaseIntensity () override
 Convert raw spectral files in directory to phase and intensity files. More...
 
bool ConvertFloatToUnsignedChar (const float *inData, unsigned char *outData, int size) const override
 Convert float data to unsigned char data. Returns true if successful.
 
bool ConvertFloatToUnsignedShort (const float *inData, unsigned short *outData, int size) const override
 Convert float data to unsigned short data. Returns true if successful.
 
bool TransposeArray (const float *src, float *dst, int inWidth, int inHeight) const override
 Transpose an array of floats. More...
 
bool TransposeArray (const unsigned short *src, unsigned short *dst, int inWidth, int inHeight) const override
 Transpose an array of shorts. More...
 
bool TransposeArray (const unsigned char *src, unsigned char *dst, int inWidth, int inHeight) const override
 Transpose an array of bytes. More...
 
bool FlipVertical (unsigned short *data, int width, int height) const override
 Flips an array (image) around its horizontal axis. More...
 
bool FlipHorizontal (unsigned short *data, int width, int height) const override
 Flips an array (image) around its vertical axis. More...
 
bool RotateImage (const unsigned short *inData, unsigned short *outData, int width, int height, unsigned int cw90Multiplier) const override
 Rotates an image by 0, 90, 180, or 270 degrees. More...
 
virtual IWPOCTConverter::ErrorCode GetLastError () const override
 Gets the result of the most current operation. More...
 
- Public Member Functions inherited from IWPOCTConverter
virtual void Dispose ()
 
virtual string GetQualifiedInputFileName ()
 
virtual string GetOutputIntensityName ()
 
virtual string GetOutputPhaseName ()
 
virtual string GetOutputDirectory ()
 
virtual string GetCalibrationFringeFile ()
 
virtual bool GetOutputIntensity ()
 
virtual bool GetOutputPhase ()
 
virtual bool GetDeleteInputFileAfterConversion ()
 
virtual bool GetOutputTiffFormat ()
 
virtual bool GetOutputLogOfData ()
 
virtual bool GetUseScaling ()
 
virtual bool GetUseContrast ()
 
virtual int GetAScansPerBScan ()
 
virtual int GetAScanSize ()
 
virtual int GetAScanAverage ()
 
virtual bool GetScanDimensions (ref int aScansPerBScan, ref int aScanSize)
 
unsafe bool GetDispersionCoefficients (float[] coefficients, int length)
 
virtual bool GetNumberOfLinesToIgnore (ref int top, ref int bottom)
 
virtual bool GetMinMaxScaling (ref float min, ref float max)
 
virtual int GetNumScanProcessors ()
 
virtual bool GetUseMovingAverage ()
 
virtual int GetMovingAverageWindowSize ()
 
virtual bool SetQualifiedInputFileName (string name)
 
virtual bool SetOutputIntensityName (string name)
 
virtual bool SetOutputPhaseName (string name)
 
virtual bool SetOutputDirectory (string name)
 
virtual bool SetCalibrationFringeFile (string name)
 
unsafe bool GetBackgroundImage (float[] buffer, int size)
 
unsafe bool SetBackgroundImage (float[] buffer, int size)
 
unsafe bool SetDispersionCoefficients (float[] coefficients, int length)
 
unsafe bool CalcDispersionCoefficients (ushort[] inData, int width, int height, float[] coefficients)
 
unsafe bool SetDispersionOptimizationParameters (int numCoefficients, int maxIterations, float[] initialGuesses, int startLine, int stopLine, int offset)
 
unsafe bool ConvertSpectralDataToIntensity (IWPOCTInOutData inOutData)
 
unsafe bool ConvertSpectralDataToIntensity (ushort[] inData, float[] outIntensity)
 
unsafe bool ConvertSpectralDataToPhaseIntensity (IWPOCTInOutData inOutData)
 
unsafe bool ConvertSpectralDataToPhaseIntensity (ushort[] inData, float[] outIntensity, float[] outPhase)
 
virtual bool ConvertSpectralFileToPhaseIntensity (string qualifiedFileName)
 
unsafe bool ConvertFloatToUnsignedChar (float[] inData, byte[] outData, int size)
 
unsafe bool ConvertFloatToUnsignedShort (float[] inData, ushort[] outData, int size)
 
unsafe bool TransposeArray (float[] src, float[] dst, int inWidth, int inHeight)
 
unsafe bool TransposeArray (ushort[] src, ushort[] dst, int inWidth, int inHeight)
 
unsafe bool TransposeArray (byte[] src, byte[] dst, int inWidth, int inHeight)
 
unsafe bool FlipVertical (ushort[] data, int width, int height)
 
unsafe bool FlipHorizontal (ushort[] data, int width, int height)
 
unsafe bool RotateImage (ushort[] inData, ushort[] outData, int width, int height, uint cw90Multiplier)
 
virtual IWPOCTConverter.ErrorCode GetLastError ()
 

Public Attributes

const int InitialNumScanProcessors = 1
 
const int MaxAScanSize = 8192
 
const int MaxAScansPerBScan = 65000
 
const int MaxNumScanProcessors = 8
 
boost::signals2::signal< void(const char *)> SignalCalibrationFileChanged
 

Protected Member Functions

void SignalProgress ()
 
bool ReadBinFileToMemory (const char *qualifiedFileName, unsigned short *outData)
 
bool WriteMemoryToFile (const char *qualifiedFileName, const U16 *inData)
 
bool WriteMemoryToFile (const char *qualifiedFileName, const float *inData)
 
string GetFileName (const string &fullName)
 

Additional Inherited Members

- Public Types inherited from IWPOCTConverter
enum  ErrorCode {
  NoError = 0 , NullPointer = 1 , FileReadError = 2 , FileWriteError = 3 ,
  FileOrDirNotFound = 4 , InvalidFileOrDirName = 5 , InvalidArgumentValue = 6 , MemoryAllocationError = 7 ,
  BackgroundUpdateError = 8 , ConversionError = 9 , CompatibleGraphicsCardNotFound = 10 , StartOpenCLError = 11 ,
  ScanProcessorInitError = 12 , DongleNotFound = 13 , NumErrors = 14 , NoError = 0 ,
  NullPointer = 1 , FileReadError = 2 , FileWriteError = 3 , FileOrDirNotFound = 4 ,
  InvalidFileOrDirName = 5 , InvalidArgumentValue = 6 , MemoryAllocationError = 7 , BackgroundUpdateError = 8 ,
  ConversionError = 9 , CompatibleGraphicsCardNotFound = 10 , StartOpenCLError = 11 , ScanProcessorInitError = 12 ,
  DongleNotFound = 13 , NumErrors = 14
}
 The following are error codes that are used within the converter object. More...
 
enum class  ErrorCode {
  NoError = 0 , NullPointer = 1 , FileReadError = 2 , FileWriteError = 3 ,
  FileOrDirNotFound = 4 , InvalidFileOrDirName = 5 , InvalidArgumentValue = 6 , MemoryAllocationError = 7 ,
  BackgroundUpdateError = 8 , ConversionError = 9 , CompatibleGraphicsCardNotFound = 10 , StartOpenCLError = 11 ,
  ScanProcessorInitError = 12 , DongleNotFound = 13 , NumErrors = 14 , NoError = 0 ,
  NullPointer = 1 , FileReadError = 2 , FileWriteError = 3 , FileOrDirNotFound = 4 ,
  InvalidFileOrDirName = 5 , InvalidArgumentValue = 6 , MemoryAllocationError = 7 , BackgroundUpdateError = 8 ,
  ConversionError = 9 , CompatibleGraphicsCardNotFound = 10 , StartOpenCLError = 11 , ScanProcessorInitError = 12 ,
  DongleNotFound = 13 , NumErrors = 14
}
 
- Static Public Member Functions inherited from IWPOCTConverter
static IWPOCTConverter GetOCTConverter ()
 
static bool DestroyOCTConverter ()
 
- Protected Attributes inherited from IWPOCTConverter
bool swigCMemOwn
 

Detailed Description

Class that converts a scanned image from one format to another.

This class is the implementation of IWPOCTConverter.

Member Function Documentation

◆ CalcDispersionCoefficients()

bool WPScanConverter::CalcDispersionCoefficients ( const unsigned short *  inData,
int  width,
int  height,
float *  coefficients 
)
overridevirtual

Calc the optimal dispersion coefficients.

Use variance to calculate the optimal dispersion coefficients.

Implements IWPOCTConverter.

◆ ConvertSpectralDataToIntensity() [1/2]

bool WPScanConverter::ConvertSpectralDataToIntensity ( const unsigned short *  inData,
float *  outIntensity 
)
overridevirtual

Convert raw spectral data to intensity array.


Parameters
inData[in]A pointer to a const unsigned short int array that contains the camera data.
outIntensity[out]A pointer to a float array. The intensity output of the conversion will be placed in this array. @Returns true if successful.

Implements IWPOCTConverter.

◆ ConvertSpectralDataToIntensity() [2/2]

bool WPScanConverter::ConvertSpectralDataToIntensity ( IWPOCTInOutData inOutData)
overridevirtual

Convert raw spectral data to intensity array.


Parameters
inOutData[inOut]A pointer to an inOutData object. This object should have the raw data set as well as the intensity data. The intensity data should be allocated by the user. @Returns true if successful.

Implements IWPOCTConverter.

◆ ConvertSpectralDirToPhaseIntensity()

bool WPScanConverter::ConvertSpectralDirToPhaseIntensity ( )
overridevirtual

Convert raw spectral files in directory to phase and intensity files.

Convert binary files in directory to phase and intensity files.

Returns true if successful.

Implements IWPOCTConverter.

◆ ConvertSpectralFileToPhaseIntensity() [1/2]

bool WPScanConverter::ConvertSpectralFileToPhaseIntensity ( )
overridevirtual

Convert raw spectral data file to phase and intensity files.

Convert binary file to phase and intensity files. Returns true if successful.

Uses _qualifiedInputFileName for input file name. Returns true if successful.

Implements IWPOCTConverter.

◆ ConvertSpectralFileToPhaseIntensity() [2/2]

bool WPScanConverter::ConvertSpectralFileToPhaseIntensity ( const char *  qualifiedFileName)
overridevirtual

Convert binary file to phase and intensity files.

Not setup to be multi=threaded.

Returns true if successful.

Implements IWPOCTConverter.

◆ FlipHorizontal()

bool WPScanConverter::FlipHorizontal ( unsigned short *  data,
int  width,
int  height 
) const
overridevirtual

Flips an array (image) around its vertical axis.

This is an inplace transformation.

Parameters
data[inOut]pointer to the input data array.
width[in]the input data width
height[in]the input data height @Returns true if successful.

Implements IWPOCTConverter.

◆ FlipVertical()

bool WPScanConverter::FlipVertical ( unsigned short *  data,
int  width,
int  height 
) const
overridevirtual

Flips an array (image) around its horizontal axis.

This is an inplace transformation.

Parameters
data[inOut]pointer to the input data array.
width[in]the input data width
height[in]the input data height @Returns true if successful.

Implements IWPOCTConverter.

◆ GetLastError()

IWPOCTConverter::ErrorCode WPScanConverter::GetLastError ( ) const
overridevirtual

Gets the result of the most current operation.

Returns
error code

Implements IWPOCTConverter.

◆ GetMovingAverageWindowSize()

virtual int WPScanConverter::GetMovingAverageWindowSize ( ) const
inlineoverridevirtual

Gets the window size of the moving average.

Returns
the moving average window size

Implements IWPOCTConverter.

◆ ResetMovingAverage()

bool WPScanConverter::ResetMovingAverage ( )
inlineoverridevirtual

Resets the moving average by clearing the buffers.


Returns
true on success

Implements IWPOCTConverter.

◆ RotateImage()

bool WPScanConverter::RotateImage ( const unsigned short *  inData,
unsigned short *  outData,
int  width,
int  height,
unsigned int  cw90Multiplier 
) const
overridevirtual

Rotates an image by 0, 90, 180, or 270 degrees.


Parameters
inData[in]pointer to the input data array.
outData[out]pointer to the output data array.
width[in]the input data width
height[in]the input data height
cw90Multiplier[in]determines the amount of rotation. The number supplied is multiplied by 90 degrees. @Returns true if successful.

Implements IWPOCTConverter.

◆ SetDispersionOptimizationParameters()

bool WPScanConverter::SetDispersionOptimizationParameters ( int  numCoefficients,
int  maxIterations,
float *  initialGuesses,
int  startLine,
int  stopLine,
int  offset 
)
overridevirtual

Set the values that are used to calculate the optimal dispersion coefficients.

Parameters
numCoefficients[in]the number of coefficients to calculate (2 is typical).
maxIterations[in]the number of iterations used to calculate each coefficient.
Accuracy improves and calculation time increases with larger values.
initialGuesses[in]array of starting dispersion guesses. Except for small values, each starting guess must be at least half of the actual value. Usually, two values are supplied here. Setting values after the first one to zero usually works.
startLine[in]the starting row of the area of the output image that is examined.
stopLine[in]the ending row of the area of the output image that is examined.
offset[in]currently unused
Returns
true on success

Implements IWPOCTConverter.

◆ SetMovingAverageWindowSize()

bool WPScanConverter::SetMovingAverageWindowSize ( int  value)
inlineoverridevirtual

Sets the window size of the moving average.

Returns
true on success

Implements IWPOCTConverter.

◆ SetUseScaling()

bool WPScanConverter::SetUseScaling ( bool  value)
inlineoverridevirtual

Set the flag that determines if scaling is used on the output.

If set to false, then UseContrast is also set to false.

Implements IWPOCTConverter.

◆ TransposeArray() [1/3]

bool WPScanConverter::TransposeArray ( const float *  inData,
float *  outData,
int  inWidth,
int  inHeight 
) const
overridevirtual

Transpose an array of floats.

Parameters
inData[in]pointer to the input data array.
outData[out]pointer to the output data array.
inWidth[in]the input data width
inHeight[in]the input data height @Returns true if successful.

Implements IWPOCTConverter.

◆ TransposeArray() [2/3]

bool WPScanConverter::TransposeArray ( const unsigned char *  src,
unsigned char *  dst,
int  inWidth,
int  inHeight 
) const
overridevirtual

Transpose an array of bytes.

Parameters
inData[in]pointer to the input data array.
outData[out]pointer to the output data array.
inWidth[in]the input data width
inHeight[in]the input data height @Returns true if successful.

Implements IWPOCTConverter.

◆ TransposeArray() [3/3]

bool WPScanConverter::TransposeArray ( const unsigned short *  inData,
unsigned short *  outData,
int  inWidth,
int  inHeight 
) const
overridevirtual

Transpose an array of shorts.

Parameters
inData[in]pointer to the input data array.
outData[out]pointer to the output data array.
inWidth[in]the input data width
inHeight[in]the input data height @Returns true if successful.

Implements IWPOCTConverter.

◆ UpdateBackgroundImage()

bool WPScanConverter::UpdateBackgroundImage ( )
overridevirtual

Update the background image used for background subtraction the next time a conversion is performed.

The new background is an average of each column of input.

Implements IWPOCTConverter.


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