FB_VN_SSIM

This FB provides the structural similarity (SSIM) functionality. First, set the reference image. Afterwards, the Compute method can be executed.

Do not call the main FB directly. Only use the available methods.

FB_VN_SSIM 1: Methods

Name

Description

Compute

Compute the structural similarity (SetReference must have been called before).

SetReference

Sets the reference image, used by the SSIM method.

Further information

The function block FB_VN_SSIM calculates the structural similarity of two grayscale images. For reference, an interference-free image is assumed.

Parameter

Input images

The reference and input image must be a 1-channel image with element type USINT (8-bit). First, the reference image must be passed using the SetReference method. After that, the execution can be done by calling the Compute method, where the input image is then passed.

Output image (return value)

The output image is of type Real and scaled to the value range 0-1. A 1 means agreement and 0 a maximum deviation.

Application

The execution consists of 2 steps. First, the reference image must be set. After that, the Compute method can be called, which is passed the current input image to be compared.

For further analysis of the result image e.g. with the F_VN_DetectBlobs function it is necessary to convert the image to a USINT. The function F_VN_ConvertElementTypeExp can be used for this purpose. Using the functions F_VN_ImageAverage or F_VN_MinPixelValue a matching value can be determined directly based on the result image.

// Set reference image first
hr := fbSSIM.SetReference(ipImage := ipRefImage);

// Check if successful, set imput image and compute the result
IF SUCCEEDED(hr) and ipRefImage <> 0 THEN
    hr := fbSSIM.Compute(ipSrcImage:= ipImageIn, ipSSIM:= ipResultImage);
    // Convert and scale the result image to USINT
    hr := F_VN_ConvertElementTypeExp(ipResultImage, ipResult2Image, ETcVnElementType.TCVN_ET_USINT, (255.0/1.0), 0, hr);
END_IF
FB_VN_SSIM 2:

High memory usage for large images

Since the function performs many calculations with real values in the background, more router memory and computing power is required depending on the image size.

Required License

TC3 Vision Matching

System Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT V3.1.4024.54 or later

PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU

Tc3_Vision