Table of Contents
Image Compress
Compresses a raw image.
Library
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
qc_open_library('quarc_library/Image Processing/Generic')Description
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'
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
doc vision;Important Notes
Output dimensions
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
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
doc simulink/width;MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
doc simulink/scope;To show the dimension of the output signal of the Image Compress block, check the 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'
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
doc vision;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
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 |
---|---|---|---|
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
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 |
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.