Leaper Vision Toolkit
中文 / English 2.x
Public Member Functions | Properties
ILImageFilter Interface Reference

This interface provide functionalities of various image filtering operations. More...

Inheritance diagram for ILImageFilter:
ILObject LImageFilter

Public Member Functions

void EdgePreserveDenoise (ILImage *img, ILImage *result, int speedupFactor, ILImage *refImg)
 
void EdgePreserveTextureEnhance (ILImage *img, ILImage *result, int speedupFactor, ILImage *refImg)
 
void Equalize (ILImage *img, ILImage *result)
 
void Gaussian (ILImage *img, ILImage *result)
 
void HighPass (ILImage *img, ILImage *result)
 
void LocalMedian (ILImage *img, ILImage *result)
 
void LocalMedianNorm (ILImage *img, ILImage *result)
 
void MeanFilter (ILImage *img, ILImage *result)
 
void OpticalDensity (ILImage *img, ILImage *result)
 
void SetKernelSigma (double kSigma, double kGain)
 
void SetKernelSize (int kWidth, int kHeight)
 
void Sharpen (ILImage *img, ILImage *result)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Properties

double KernelGain [get]
 The gain value for filter kernel. More...
 
int KernelHeight [get]
 The height of the kernel size. More...
 
double KernelSigma [get]
 The sigma value for filter kernel. More...
 
int KernelWidth [get]
 The width of the kernel size. More...
 

Detailed Description

This interface provide functionalities of various image filtering operations.

In a vision system, it's common to use image filtering operations to do pre-processing before detection and inspection task, in order to smooth, denoise, enhance or normalize the input image. The most common type of filters are linear, in which an output pixel's value is determined as a weighted sum of input pixel values:

\[ I'(x,y) = \sum_{i,j} f(x+i, y+j) k(i,j) \]

@math_eq{k(i,j)} is called the filtering kernel.

To use this interface, you should create a LImageFilter object.

Example Code

Member Function Documentation

◆ EdgePreserveDenoise()

void EdgePreserveDenoise ( ILImage img,
ILImage result,
int  speedupFactor,
ILImage refImg 
)

Smooth out image noise while retaining sharp edges. The smoothness of the denoising process is controlled by KernelSigma value with recommended value in 0.01 ~ 0.1.

Parameters
[in]imgThe input image
[out]resultReturn result image
[in]speedupFactorTo speed-up the algorithm, the suggested values are factors of the kernel's size or 1 (no speed-up).
[in]refImgOptional. The reference image provides additional edge information such as the approximate location and intensity of the edges that need to be preserved for the noise reduction process. It should have the same size as the input image.
Since
2.7.0

◆ EdgePreserveTextureEnhance()

void EdgePreserveTextureEnhance ( ILImage img,
ILImage result,
int  speedupFactor,
ILImage refImg 
)

Enhance the texture on image while retaining sharp edges. The smoothness of the enhancing process is controlled by KernelSigma value with recommended value in 0.01 ~ 0.1.

Parameters
[in]imgThe input image
[out]resultReturn result image
[in]speedupFactorTo speed-up the algorithm, the suggested values are factors of the kernel's size or 1 (no speed-up).
[in]refImgOptional. The reference image provides additional edge information such as the approximate location and intensity of the edges that need to be preserved for the texture enhancing process. It should have the same size as the input image.
Since
2.7.0

◆ Equalize()

void Equalize ( ILImage img,
ILImage result 
)

Equalizes the histogram of the input grayscale image. It will normalizes the brightness and increases the contrast of the image. This operation is not a linear filter, thus does not use the kernel size.

Parameters
[in]img The input image
[out]result Return result image

◆ Gaussian()

void Gaussian ( ILImage img,
ILImage result 
)

Blurs an image using a Gaussian filter. Two x and y order Gaussian kernel is computed as a @math_eq{\texttt{ksize} \times 1} matrix of coefficients:

\[ G_i= \alpha *e^{-(i-( \texttt{ksize} -1)/2)^2/(2* \texttt{sigma}^2)}, \]

where @math_eq{i=0..\texttt{ksize}-1} , @math_eq{\alpha} is the scale factor chosen so that @math_eq{\sum_i G_i=1} , @math_eq{sigma} is set via SetKernelSigma() or computed from ksize as @math_eq{ksize \times 0.6} .

Parameters
[in]imgThe input image
[out]resultReturn result image

◆ HighPass()

void HighPass ( ILImage img,
ILImage result 
)

Edges are enhanced relative to areas with more consistent greyscale gradient. High-pass filtering is the equivalent of subtracting Gaussian blur image from input image.

Parameters
[in]imgThe input image
[out]resultReturn result image
See also
Gaussian()

◆ LocalMedian()

void LocalMedian ( ILImage img,
ILImage result 
)

Each output pixel represents the median pixel value of the pixel values in the kernel neighborhood.

Parameters
[in]imgThe input image. For non-squared or kernel size larger than 5, only 8bit images are supported.
[out]resultReturn result image

◆ LocalMedianNorm()

void LocalMedianNorm ( ILImage img,
ILImage result 
)

Used to subtract the background from an image. This filter is the equivalent of subtracting the local median from the input image, shifts the result right by one, and then adds 128.

Parameters
[in]imgThe input image. For non-squared or kernel size larger than 5, only 8bit images are supported.
[out]resultReturn result image

◆ MeanFilter()

void MeanFilter ( ILImage img,
ILImage result 
)

Each output pixel represents the mean pixel value of the pixel values in the kernel neighborhood. The @math_eq{3 \times 3} kernel is as below:

Parameters
[in]imgThe input image
[out]resultReturn result image

◆ OpticalDensity()

void OpticalDensity ( ILImage img,
ILImage result 
)

Reveals the density of objects and features in the input image by measuring the amount of light that passes through them. Denser objects and features are represented by lighter pixels in the output image. This filter is the equivalent of @math_eq{45*(ln(255) - ln(I))} for a 8bit image, and @math_eq{5909*(ln(65535) - ln(I))} for a 16bit image.

Parameters
[in]imgThe input image
[out]resultReturn result image

◆ SetKernelSigma()

void SetKernelSigma ( double  kSigma,
double  kGain 
)

Change the kernel using the specified sigma and gain value.

Parameters
[in]kSigmaThe sigma value is used to control the filter kernel's smoothness.
For HighPass(), Gaussian() and Sharpen() functions, if the sigma value is set to 0 then it's computed as @math_eq{1/6} of the kernel size.
If the kernel size is set to all zeros, then we'll compute a proper size from the sigma value, it's around @math_eq{6 \times kSigma} .
For EdgePreserveDenoise() and EdgePreserveTextureEnhance(), set sigma value to 0 means no extra smoothing.
[in]kGainThe gain value is used to for Sharpen() to controls the overall strength of the sharpening effect.
See also
SetKernelSize(), HighPass(), Gaussian(), Sharpen()

◆ SetKernelSize()

void SetKernelSize ( int  kWidth,
int  kHeight 
)

Change kernel size used in the filter, by default it's a @math_eq{3 \times 3} kernel. Large kernel size results usually in stronger filtering effect, but also slower.
You may set the kernel size to 0 then we'll compute a proper size from the sigma value.

Parameters
[in]kWidthThe width of the kernel size, should be an odd number, say, 3, 5, 7, etc.
[in]kHeightThe height of the kernel size, should be an odd number, say, 3, 5, 7, etc.
See also
SetKernelSigma()

◆ Sharpen()

void Sharpen ( ILImage img,
ILImage result 
)

Emphasize texture and make the edges crisper and better defined. The strength of the sharpening effect is controlled by the kernel's size, KernelSigma and KernelGain value.

Parameters
[in]imgThe input image
[out]resultReturn result image

Property Documentation

◆ KernelGain

double KernelGain
get

The gain value for filter kernel.

See also
SetKernelSigma()

◆ KernelHeight

int KernelHeight
get

The height of the kernel size.

See also
SetKernelSize(), SetKernelSigma()

◆ KernelSigma

double KernelSigma
get

The sigma value for filter kernel.

See also
SetKernelSigma()

◆ KernelWidth

int KernelWidth
get

The width of the kernel size.

See also
SetKernelSize(), SetKernelSigma()