Image Compare Image Convert navigation bar

Table of Contents

Image Compress

Compresses a raw image.

Library

QUARC Targets/Image Processing/Generic

Description

Image Compress

The Image Compress block compresses a raw image into a variable-size uint8 signal.

Since compressed images are supported by the Video Display block (which displays images on the host), this block may be used to reduce network bandwidth by allowing compressed images rather than raw images to be transmitted. It also helps reduce the memory requirements for Simulink's external mode buffers which is important when using regular Scopes while displaying images.

The Image Compress block supports both RGB (HxWx3) and 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.

Important Notes

Output dimensions

Note If the Output dimension is too small, the output signal may not be large enough to hold the compressed image. In this case, a QERR_COMPRESSED_IMAGE_TOO_LARGE error occurs and the output image will be empty. Increase the size of the Output dimension parameter in this case. However, try to keep it as small as possible to minimize the amount of memory and transmission bandwidth required for the image if it is being displayed.

To view the number of bytes in the compressed image, wire a Simulink Width block to the output of the Image Compress block and wire a Scope block to the output of the Width block.

To show the dimension of the output signal of the Image Compress block, check the Display/Signals & Ports/Signal Dimensions menu item. This dimension reflects the maximum size of the compressed image as well as the number of bytes that will be transmitted to the host each sampling instant. Ideally, this dimension would be as small as possible, but still large enough to hold any compressed image.

Input Ports

image

The input may be an RGB image specified as a three-dimensional MxNx3 matrix where M is the image height and N is the image width. It contains the red, green and blue components for each pixel in the image.

It may also be a grayscale image specified as a two-dimensional MxN matrix. where M is the image height and N is the image width. It contains the luminance for each pixel in the image.

The interpretation of the data depends on the data type. Floating-point types should have elements in the range 0 to 1. Both single and double floating-point types are supported. For integer types, only unsigned integer types are supported. The range of unsigned integer types should be the full range for the integer type.

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

quality

This optional input is only available when the Source of quality parameter is set to "External input port". When enabled, this input configures the quality of the compressed image.

Output Ports

image

The output data type and dimensions depend on the Algorithm selected, but the output is typically a variable-size signal of the uint8 data type. The output contains the compressed image.

Parameters and Dialog Box

Image Compress

Algorithm

The compression algorithm to use. The algorithm will determine the data type of the output, and possibly the dimensions.

Source of quality

Select "Internal dialog parameter" to use the Quality parameter as the value for the quality of the compressed image. Choose "External input port" to enable a second input port that will be used to set the quality of the compressed image. Using an external input port allows the quality to be changed dynamically. For instance, quality could be reduced when WiFi signal strength is low to reduce the bandwidth requirements of transmitting the compressed image.

Quality (tunable offline)

For lossy compression algorithms, like JPEG, this parameter determines the quality of the compressed image. It is expressed as a percentage from 0 to 100. The default quality is 50%.

Output dimension

This parameter determines the maximum dimension of the output signal. If it is a positive value, then it is the maximum number of elements in the output vector.

If it is a negative value, then it is treated as a scale factor. The maximum number of elements in the output vector is then the number of elements in the input image multiplied by this scale factor. For example, a value of -0.1 will result in an output vector that is 10% of the size of the input image as a vector.

Note that this parameter should ideally be such that the output dimensions are as small as possible. However, the output must be large enough to hold the compressed image or no output will be produced.

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

No

No

Not currently supported.

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