Scale Image in 2D ROI

You are currently viewing the documentation for the latest version (2.2.0). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

Function

Scale the region of ​​interest (ROI) in an image to a specified size.

scale image in 2d roi function description

Usage Scenario

It is usually used for image preprocessing in deep learning related Steps and is usually used with Recover Scaled Images in 2D ROI and deep learning related steps.

Input and Output

Input

Input port Data type Description

Original Image

Image

2D image (if processing multiple images at the same time, please increase/decrease the number of input ports in the parameters).

Output

Output port Data type Description

ROI Image

Image

Image of the ROI selection area.

Scale Parameters

JsonValue

Scaling parameters (usually used in "Recover Scaled Images in 2D ROI").

ROI Parameters

Number[]

ROI parameters (usually used in "Recover Scaled Images in 2D ROI").

Visualization Image

Image

Output image with ROI.

Instruction

This Step is used to scale images in the ROI into a designated size by setting the parameter Color ROI Settings and Ideal Destination Resolution.

Auto Scale

To auto scale the ROI, please follow these steps:

  1. Select the checkbox Auto Scale under Color ROI Settings.

  2. Select the checkbox Same as Input Color ROI & Skip Scaling under Ideal Destination Resolution.

Output Initial ROI Image

To output the initial ROI image, please follow these steps:

  1. Disable Auto Scale under Color ROI Settings.

  2. Set 1 as the value of Customized Scale.

  3. Select the checkbox Same as Input Color ROI & Skip Scaling under Ideal Destination Resolution.

Scale ROI Image by a Particular Degree

To output ROI image of a particular size, please follow these steps:

  1. Disable Auto Scale under Color ROI Settings.

  2. Set Customized Scale according to your need. When the value of this parameter is higher than 1, image will be magnified. If the value is lower than 1, image will be reduced.

  3. Select the checkbox Same as Input Color ROI & Skip Scaling under Ideal Destination Resolution.

Output ROI Image of Designated Width and Height

To out put ROI image of designated width and height, please follow these steps:

  1. Disable the Same as Input Color ROI & Skip Scaling under Ideal Destination Resolution.

  2. Set the value of Width and Height according to your need.

  3. Choose whether to select Padding according to your need.

Please continue your reading to view the description of parameters.

Parameter Description

Parameter Description

Number of Input Ports (1–8)

Parameter description: This parameter specifies the number of input ports for this Step.

Color ROI Settings

ROIByFile

Parameter Description

Color ROI File

Description: This parameter sets the ROI of color image. Please refer to Set 2D ROI for more information. In the image below, point A is the top left vertex, and B is the bottom right vertex.

scale image in 2d roi roi by file

The coordinate of the upper left corner of the original image is (0, 0).

ROIByParam

Parameter Description

Start X

Description: the x-coordinate of the ROI’s top left vertex.
Default value: 0
Instruction: Start X + Width < Initial image width

Start Y

Description: the y-coordinate of the ROI’s top left vertex.
Default value: 0
Instruction: Start Y + Height < Initial image height

Width

Instruction: This parameter refers to the width of the ROI.
Default value: 0
Instruction: Start X + Width < Initial image width

Height

Instruction: This parameter refers to the height of the ROI.

Default value: 0

Instruction: Start Y + Height < Initial image height

scale image in 2d roi roi by param

The coordinate of the upper left corner of the original image is (0, 0).

Parameter Description

Method to Update Color ROI

Description: This parameter decides the type of ROI.
Options:
Original 2D image: The original color image of the ROI.
Adaptive image border: Use the border of the image to adjust the color ROI, and adaptively adjust the center of the image’s non-zero point to the center of the ROI.
Bounding rectangle: Extract the bounding rectangle area of the input image and replace the original image with the circumscribed rectangle of the non-zero point of the image to calculate the zoom ratio.

Color ROI Scaling

Parameter Description

Auto Scale

Description: This parameter automatically adjusts the size of the ROI image.
Default setting: selected.

Customized Scale

Description: This parameter designates the degree to which the ROI is scaled.

Instruction: Scaled image size = Initial ROI size × Customized scaling factor. As shown below, the image on the left is of the initial size, with a customized scaling factor of 0.5.

You can set the parameter only when Auto Scale is not selected.

Ideal Destination Resolution

Parameter Description

Same as Input Color ROI & Skip Scaling

Description: This parameter decides whether the size of the image output is set the same as that of the image after Color ROI Scaling setting.

Default setting: unselected.

When this checkbox is not selected, the size of the image output will be scaled.

Width/Height

Description: This parameter sets the width and height of the ROI (in px).

Default value: 1024 px

Tuning recommendation: Please set the parameter according to the actual situation.

You can set the parameter only when Ideal Destination Resolution is not selected.

Padding Color

Parameter Description

Padding

Description: This parameter is used to fill the extra space of the ROI when it is scaled up to a particular size.

Default setting: selected.

Instruction: It is recommended to fill the space with black (0,0,0) or grey (128,128,128).

Adjustment Example: The image on the left below is the scaled-up ROI without padding. When padding is used, the size of the ROI image must be designated, and the extra space will be filled up by color, as the image on the right side shows below.

scale image in 2d roi scale filling

R/G/B

Description: Color image is made up of three colors: R, G, and B. Different R/G/B values can fill the image with different colors.
Default value: 0
Value range: 0–255.

Is this page helpful?

You can give a feedback in any of the following ways:

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.