Crop, Pad, or Resize Images
Usage Scenario
This Step is widely used for image processing, and there is no specific usage scenario.
Input and Output
Input
| Input ports | Data type | Description |
|---|---|---|
Image |
Image |
Image to be processed |
Alignment parameter group |
Pose2D |
Used to adjust the feature region’s pose in sync with the target object’s pose changes. |
Output
| Output ports | Data type | Description |
|---|---|---|
Processed images |
Image / Image[] |
Image generated after cropping, padding, or resizing. For padding or resizing, the output is Image. For cropping, if Merge Cropping Results is selected, the output is Image; otherwise, the output is Image[]. |
Scale parameters |
JsonValue |
Scale-related information output after padding or resizing, including whether to pad ( For padding, the scaling ratio is 1; for resizing, the scaling ratio is the smaller of Target Width to Original Image Width Ratio and Target Height to Original Image Height Ratio. |
ROI parameters |
Number[] |
The output ROI-related parameter information after padding or resizing. It corresponds to the size of the original image. |
Parameter Description
| Parameter | Description |
|---|---|
Operation |
This Step is used to select the operation to be performed on the input image, including cropping, padding, or resizing.
|
Cropping Parameters
| Parameter | Description |
|---|---|
ROI settings |
Set the ROI to determine the cropping range of the image. After the Step is run, only image regions in the ROI will be retained. If the ROI is not set, no cropping is performed. |
Merge Crop Results |
Once this option is selected, the relative positions of the cropping regions in the original image will be retained, and all the cropping regions will be output in one image. When this option is not selected, one image will be output per cropping region. |
Padding Parameters
| Parameter | Description |
|---|---|
Target width |
This parameter is used to set the width (in pixels) of the padded image. |
Target height |
This parameter is used to set the height (in pixels) of the padded image output. |
Pad Color |
The R channel padding value used to specify the extended region of the image. If a grayscale image is input, only the value of the R channel takes effect and serves as the grayscale value for padding. |
Pad Color (G) |
The G-channel padding value used to specify the extended region of the image. Only takes effect when the input is a color image. |
Pad Color (B) |
The B-channel padding value used to specify the extended region of the image. Only takes effect when the input is a color image. |
Scale Parameters
| Parameter | Description |
|---|---|
Lock aspect ratio |
Once this option is selected, the ratio of the target width to the target height will be locked, and each time you modify one item, the other item will be automatically scaled. |
Target width |
This parameter specifies the final width value of the scaled image. |
Target height |
This parameter specifies the final height value of the scaled image. |
Resize after padding |
When enabled (default), the image retains its original aspect ratio, scales to fit the target size, and pads any blank areas with black, resulting in no distortion. When this option is not selected, the image will be stretched or compressed to fit the target size, and the image may be deformed. |
Troubleshooting
Filling Operation Not Taking Effect
Symptom:
The target width or height is smaller than the size of the input image, and the padding operation has not taken effect. The size of the output image is the same as the input image.
Possible Cause:
The set target width or height is smaller than or equal to the actual size of the input image, and thus the padding operation cannot be performed.
Solution:
Check and adjust the Target Width and Height parameters to ensure that they are larger than the dimensions of the input image, and then re-run the Step.