SK91USB3-LX  1.2.0
Functions
Pixel Correction

This page describes the functions for Shading Correction or the look-up-table function. More...

Functions

int SK_SETSCM (int CamID, void *pData, int bitDepth, int bytesPerLine, int linesPerImage, int relMin, int relMax)
 Acquires new reference profile. More...
 
unsigned short * SK_GETSCMPTR (int CamID)
 Returns the pointer to the SCM buffer inside of DLL. More...
 
int SK_SCMTOFLASH (int CamID)
 Writes the correction profile from the SCM into the camera flash memory. More...
 
int SK_FLASHTOSCM (int CamID)
 Loads the shading correction profile from the camera flash memory into the SCM. More...
 
int SK_SHADCORR (int CamID, bool ON)
 Activates and deactivates the shading correction. More...
 
int SK_SAVESCM (int CamID, const char *fileName)
 Saves the current SCM (Shading Correction Memory) to a file. More...
 
int SK_LOADSCM (int CamID, const char *fileName, unsigned short *pData)
 Loads a shading correction profile into the SCM from a file, or from a buffer. More...
 
int SK_SCMTOVIDEO (int CamID, bool ON)
 Outputs the programmed Shading Correction Memory as camera signal. More...
 
int SK_READSCM (int CamID, int flashID)
 Reads the stored shading correction profile from camera flash memory into the volatile SCM. More...
 
int SK_LENSVIGNETTINGCORR (int CamID, double FocalLength, double SensorLength, double FOV)
 Correction of natural lens vignetting using Shading Correction function. More...
 
int SK_SETLUT (int CamID, unsigned short opMode, double param)
 Calculates a pixel transformation function and writes it into the lookup table (LUT) inside the camera. More...
 
int SK_LUTTOFLASH2 (int CamID)
 Writes the Lookup Table from the LUT memory into the camera flash memory. More...
 
int SK_FLASH2TOLUT (int CamID)
 Loads the look up table from the camera flash memory into the LUT memory. More...
 
int SK_LUTCORR (int CamID, bool ON)
 Activates and deactivates the LUT (look up table) correction. More...
 
int SK_GETLUTSTATUS (int CamID, unsigned short *opMode, double *param)
 Returns LUT status of camera. More...
 

Detailed Description

This page describes the functions for Shading Correction or the look-up-table function.

Shading Correction

SCM_Structure.png

Shading Correction compensates for non-uniform illumination, lens vignetting as well as any differences in pixel sensitivity. The signal from a white homogeneous background is obtained and used as a reference to correct each pixel of the sensor with an individual factor, scaled up to an programmable unitary intensity level to provide a flat signal. The reference signal is stored in the SCM (Shading Correction Memory) of the camera and subsequent scans are normalized using the scale factors from this white reference.

If Shading Correction is active at shutdown, the camera will load the stored reference signal from the flash into the SCM at the next start. If the load process completes then the Shading Correction is active.

How to perform Shading Correction

Use a homogeneous white object for the acquisition of a reference. The reference can be a grabbed 2-dimensional scan about a determined number of lines (call this function from an Area Scan - recommended) or a line signal which was averaged over a number of single line scans. During the image acquisition the white object should be moved to suppress influences of surface structures.

Look up Table

The Lookup Table (LUT) is a pre-processing inside the camera. By programming a transformation function, brightness values of the camera are converted to other values. The transformation of image data can be useful to get better imaging results, e.g. more contrast or higher dynamic. This version supports Gamma Correction (convex: gamma > 1.0, concave: gamma < 1.0), and Linear Function with factor. The Linear LUT with factor 1.0 provides the unchanged image data.

Function Documentation

int SK_FLASH2TOLUT ( int  CamID)

Loads the look up table from the camera flash memory into the LUT memory.

Remarks
After calling this function, the Lookup Table is activated.
This function runs at the beginning of each camera session automatically inside the initialization procedure. Whether the LUT here is activated or not, depends on the status of the previous session.
Since
version 1.2.0 and camera revision 1.22 / 2.22
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_FLASHTOSCM ( int  CamID)

Loads the shading correction profile from the camera flash memory into the SCM.

Remarks
After calling this function, the shading correction is activated.
This function runs at the beginning of each camera session automatically inside the initialization procedure. Whether the shading correction here is activated or not, depends on the status of the previous session.
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_GETLUTSTATUS ( int  CamID,
unsigned short *  opMode,
double *  param 
)

Returns LUT status of camera.

Since
version 1.2.0 and camera revision 1.22 / 2.22
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
[out]opModeLUT type
[out]paramparameter
Returns
0 = LUT off
1 = LUT on
else see Error Code Table
unsigned short* SK_GETSCMPTR ( int  CamID)

Returns the pointer to the SCM buffer inside of DLL.

Remarks
The Shading Correction memory has a unsigned short format (16 bit per value).
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
Returns
pointer to shading correction memory or nullptr at error
int SK_LENSVIGNETTINGCORR ( int  CamID,
double  FocalLength,
double  SensorLength,
double  FOV 
)

Correction of natural lens vignetting using Shading Correction function.

This function calculates the natural lens profile and corrects it. The edge intensities are increased, e.g. the lower the focal length value the higher the corrected intensity.

This function doesn't need any reference image of a white object.

Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
FocalLengthfocal length of used lens in millimeters (mm)
SensorLengthlength of sensor in millimeters (mm)
FOVfield of view in millimeters (mm)
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_LOADSCM ( int  CamID,
const char *  fileName,
unsigned short *  pData 
)

Loads a shading correction profile into the SCM from a file, or from a buffer.

Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
fileNamename of a file which contains valid SCM data,
must be NULL if pData is the source of SCM data.
pDatapointer to a user managed buffer which contains valid SCM data in a 12 bit format.
Remarks
If fileName == NULL and pData == NULL, the shading correction uses the current contain of SCM.
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_LUTCORR ( int  CamID,
bool  ON 
)

Activates and deactivates the LUT (look up table) correction.

Since
version 1.2.0 and camera revision 1.22 / 2.22
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
ONtrue = LUT is active
false = no pixel conversion
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_LUTTOFLASH2 ( int  CamID)

Writes the Lookup Table from the LUT memory into the camera flash memory.

Remarks
The camera maintains the Lookup Table permanently, also if the camera is power-off.
Since
version 1.2.0 and camera revision 1.22 / 2.22
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_READSCM ( int  CamID,
int  flashID 
)

Reads the stored shading correction profile from camera flash memory into the volatile SCM.

Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
flashID0 (default) = Shading Correction Memory
1 = LUT Memory
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_SAVESCM ( int  CamID,
const char *  fileName 
)

Saves the current SCM (Shading Correction Memory) to a file.

Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
fileNamefile name as string
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_SCMTOFLASH ( int  CamID)

Writes the correction profile from the SCM into the camera flash memory.

Remarks
The camera maintains the shading correction profile permanently, also if the camera is power-off.
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_SCMTOVIDEO ( int  CamID,
bool  ON 
)

Outputs the programmed Shading Correction Memory as camera signal.

Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
ONtrue = the output camera signal is the content of SCM.
false = the output is the sensor signal.
Remarks
This function is suitable for diagnosis of shading correction.
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_SETLUT ( int  CamID,
unsigned short  opMode,
double  param 
)

Calculates a pixel transformation function and writes it into the lookup table (LUT) inside the camera.

Since
version 1.2.0 and camera revision 1.22 / 2.22
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
opMode0 = linear
1 = gamma
paramlinear: factor
gamma: exponent 1/gamma
Remarks
The linear LUT with factor 1.0 supplies the unchanged image data from sensor. It is realized by deactivation the LUT, no transformation function is calculated.
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_SETSCM ( int  CamID,
void *  pData,
int  bitDepth,
int  bytesPerLine,
int  linesPerImage,
int  relMin,
int  relMax 
)

Acquires new reference profile.

This function calculates a new reference profile for shading correction and stores it into the shading correction memory (SCM).

With pData = nullptr, a new reference image is acquired by this function itself. If pData is a valid pointer, the correction profile will be calculated by pixel wise averaging of this image data.

Note
A very low value for relMin (e.g. < 4) increases noise in the signal.
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
pDatapointer to a reference image, nullptr = grab new image
bitDepthbit depth, if a reference image is given, else 12 bit is used
bytesPerLinenumber of bytes per line
linesPerImagenumber of lines of the reference image, given or to acquire
relMinin % (percent) of absolute maximum, e.g. relMin = 10, at 8 bit minimum = 25, at 12 bit minimum = 409
the algorithm uses only pixels with higher intensity than minimum, pixels with lower intensity will be unchanged
relMaxin % (percent) of absolute maximum, e.g. relMax = 90, at 8 bit maximum = 230, at 12 bit maximum = 3686
the algorithm scales each pixel to maximum, the result is a flat profile at maximum
If relMax is 0, the scaled maximum will be equal to the signal maximum.
Returns
SK_RESULT_OK on success, else see Error Code Table
int SK_SHADCORR ( int  CamID,
bool  ON 
)

Activates and deactivates the shading correction.

Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
ONtrue = shading correction active
false = shading correction OFF
Returns
SK_RESULT_OK on success, else see Error Code Table