Image Align Image Compress navigation bar

Table of Contents

Image Compare

Compares pixels of an image to given ranges.

Library

QUARC Targets/Image Processing/Generic

Description

Image Compare

The Image Compare block compares the pixels in the input image to given ranges. The output is one or more bitonal images whose pixels are 255 if the condition for that pixel is true and 0 otherwise. The output images are suitable as a bitmask or with blocks such as the Image Find Objects block.

There are two fundamental types of comparisons, saturating and wrapping. The normal, or saturating, comparisons simply compare each pixel to the minimum and maximum values and output the result. In this case, minimum and maximum values are saturated to the range of the input image's data type prior to performing the comparison.

In the wrapping comparisons, the minimum and maximum values are truncated to the range of the input image's data type so that they wrap around like a circular buffer or modulus arithmetic. However, the wrapping comparison takes this roll-over into account.

Wrapping comparisons are useful for input images such as hue, saturation and value. For example, when tracking changing hue values consider minimum and maximum values and an in-range comparison such as min ≤ x ≤ max, as shown below (for a uint8 HSV image):

     
0
min
max
255

White indicates the range of pixel values for which the comparison is true (pixel value of 255 will be output) and black indicates the range of pixel values for which the comparison is false (pixel value of 0 will be output).

If the comparison range is kept the same but the minimum value is increased until the maximum exceeds the limit of the data type (255 in this example) then in a normal (saturating) comparison, the result will be:

   
0
min
255

but in a wrapping comparison, the result will be:

     
0
max
min
255

The Image Compare block supports both MATLAB RGB (HxWx3) and MATLAB grayscale (HxW) inputs. A variety of different input data types are supported that are compatible with The MathWorks' Computer Vision System Toolbox, including both integer and floating-point data types.

Input Ports

image

The input image whose pixel values will be compared to the selected ranges.

min

A vector of minimum range values. If the image input is RGB then this vector must be a 3-vector. Otherwise it should be a scalar. Any of the standard Simulink data types are supported, other than fixed point. This port is only present if the Source of ranges parameter is set to External input ports.

max

A vector of maximum range values. If the image input is RGB then this vector must be a 3-vector. Otherwise it should be a scalar. Any of the standard Simulink data types are supported, other than fixed point. This port is only present if the Source of ranges parameter is set to External input ports.

Output Ports

image1

The result of the comparison for the primary plane (red or grayscale) of the input image or for all planes, depending on the Output type parameter. The output is a bitonal image of the same height and width as the input image. Its pixels will be 255 if the result of the comparison is true and zero otherwise.

The output is compatible with The MathWorks' Computer Vision System Toolbox.

image2

This output is only present if the input is RGB and the Output type parameter is set to Separate planes (3 HxW outputs). It is the result of the comparison for the secondary plane (green) of the input image. The output is a bitonal image of the same height and width as the input image. Its pixels will be 255 if the result of the comparison is true and zero otherwise.

The output is compatible with The MathWorks' Computer Vision System Toolbox.

image3

This output is only present if the input is RGB and the Output type parameter is set to Separate planes (3 HxW outputs). It is the result of the comparison for the tertiary plane (blue) of the input image. The output is a bitonal image of the same height and width as the input image. Its pixels will be 255 if the result of the comparison is true and zero otherwise.

The output is compatible with The MathWorks' Computer Vision System Toolbox.

Parameters and Dialog Box

Image Compare

Output type

The type of output from the block. If this option set set to Separate planes (three HxW outputs) then the block will have three outputs. In this case, the input must be an RGB image. The first output will be the result of the primary (red) comparison on the red plane. The second output will be the result of the secondary (green) comparison for the green plane, and the third output will be the result of the tertiary (blue) comparison for the blue plane of the input image.

All outputs will be bitonal. Each pixel will be either 0 or 255 depending on whether the result of the comparison for that pixel is false or true respectively.

If this option is set to Per plane color image (one HxWx3 output) then there will only be one output. If the input is an RGB image then it will be an RGB output where each plane is bitonal. The red plane will be the result of the primary (red) comparison on the red plane of the input. The green plane will be the result of the secondary (green) comparison on the green plane of the input, and the blue plane will be the result of the tertiary (blue) comparison on the blue plane of the input. The terms primary, secondary and tertiary are used because the input can be any HxWx3 matrix, such as an HSV image instead of RGB, in which case the hue is the primary plane, saturation is the secondary plane and value is the tertiary plane.

If the input is grayscale (HxW) then the output will also be a grayscale (HxW) image and only the primary comparison will be used.

Each plane of the output will be bitonal. Each pixel will be either 0 or 255 depending on whether the result of the comparison for that pixel is false or true respectively.

If this option is set to Combined (one HxW output) then the comparisons are done on the respective color planes of the input image and the results are logically ANDed together for each pixel to form a bitonal HxW output image. Each pixel will be either 0 or 255 depending on whether the result of the comparisons for that pixel are false or true respectively. In other words, if the red condition and green condition and blue condition are true then the output will be true (255). Otherwise the output pixel will be false (0).

If the input is grayscale (HxW) then the output will also be a grayscale (HxW) image and only the primary comparison will be used.

Source of ranges

This option selects whether the minimums and maximums are specified in dialog parameters or external input ports. If this option is set to Internal dialog parameters then the minimums and maximums are specified in the dialog.

If this option is set to External input ports then two more inputs ports are provided. The min input must contain a vector of minimum range values and the max input must contain a vector of maximum range values. If the image is RGB then these vectors must be 3-vectors, with one element for each color plane. If the input image is grayscale, then these range inputs should be scalars.

Primary plane comparison (tunable online)

The type of comparison to perform for the primary plane, if the input is RGB (HxWx3), or for the entire image if the input is grayscale (HxW). All possible combinations of the pixel being within the range or outside the range are possible. The range is defined by the Primary plane minimum range and Primary plane maximum range parameters.

Primary plane minimum range (tunable online)

The minimum value of the range in the primary plane comparison. This parameter is present if the Source of ranges parameter is set to Internal dialog parameters.

Primary plane maximum range (tunable online)

The maximum value of the range in the primary plane comparison. This parameter is present if the Source of ranges parameter is set to Internal dialog parameters.

Secondary plane comparison (tunable online)

The type of comparison to perform for the secondary (green) plane. All possible combinations of the pixel being within the range or outside the range are possible. The range is defined by the Secondary plane minimum range and Secondary plane maximum range parameters.

Secondary plane minimum range (tunable online)

The minimum value of the range in the secondary plane comparison. This parameter is present if the Source of ranges parameter is set to Internal dialog parameters.

Secondary plane maximum range (tunable online)

The maximum value of the range in the secondary plane comparison. This parameter is present if the Source of ranges parameter is set to Internal dialog parameters.

Tertiary plane comparison (tunable online)

The type of comparison to perform for the tertiary (green) plane. All possible combinations of the pixel being within the range or outside the range are possible. The range is defined by the Tertiary plane minimum range and Tertiary plane maximum range parameters.

Tertiary plane minimum range (tunable online)

The minimum value of the range in the tertiary plane comparison. This parameter is present if the Source of ranges parameter is set to Internal dialog parameters.

Tertiary plane maximum range (tunable online)

The maximum value of the range in the tertiary plane comparison. This parameter is present if the Source of ranges parameter is set to Internal dialog parameters.

Targets

Target Name

Compatible*

Model Referencing

Comments

QUARC Win32 Target

Yes

Yes

QUARC Win64 Target

Yes

Yes

QUARC Linux Nvidia Target

Yes

Yes

QUARC Linux QBot Platform Target

Yes

Yes

QUARC Linux QCar 2 Target

Yes

Yes

QUARC Linux QDrone 2 Target

Yes

Yes

QUARC Linux Raspberry Pi 3 Target

Yes

Yes

QUARC Linux Raspberry Pi 4 Target

Yes

Yes

QUARC Linux RT ARMv7 Target

Yes

Yes

QUARC Linux x64 Target

Yes

Yes

QUARC Linux DuoVero Target

Yes

Yes

QUARC Linux DuoVero 2016 Target

Yes

Yes

QUARC Linux Verdex Target

Yes

Yes

QUARC QNX x86 Target

Yes

Yes

Last fully supported in QUARC 2018.

Rapid Simulation (RSIM) Target

Yes

Yes

S-Function Target

No

N/A

Old technology. Use model referencing instead.

Normal simulation

Yes

Yes

* Compatible means that the block can be compiled for the target.

 

navigation bar