Scaling

The Scaling camera feature allows you to shrink the size of an image.

When the Scaling feature is used, Binning and Decimation are not available.

In this topic Hide

Using the Feature

Prerequisites

How It Works

During scaling, the image size is reduced proportionally by interpolation. Pixel values are added and averaged as required to map them to the pixels of the scaled image. This increases the signal-to-noise ratio.

Scaling is controlled by the scaling factor that you choose. The same factor is applied in horizontal and vertical direction. With a factor of 1.0, the image size stays the same. A factor smaller than 1.0 causes the image width and height to shrink.

Configuring Scaling

To adjust scaling, specify a scaling value for the ScalingHorizontalAbsScalingHorizontal parameter.

Changing the ScalingHorizontalAbsScalingHorizontal parameter value automatically adapts the ScalingVerticalAbsScalingVertical parameter value. This maintains the original height-to-width ratio.

Scaling Values

You can choose a scaling factor from 0.125 to 1. However, only 112 discrete values are available. If you enter a value that is not available, the float control automatically rounds up or down to the nearest available value.

To calculate valid values use the following formula: 16/x, where x = any natural number between 16 to 128.

Examples Resulting Scaling Factor Consequences

16 / 16

1.0

Default setting. Scaling is disabled. No change to the original image size.

Binning and Decimation are available.

16 / 17

0.941

 

16 / 18

0.888

 

and so on

...

 

16 / 32

0.5

The image size is reduced by half (factor 2).
16 / 64

0.25

The image size is reduced by factor 4.

and so on

...

 

16 / 128

0.125

The image size is reduced by factor 8 (largest reduction).

Considerations When Using Scaling

Effect on ROI Settings

When you are using scaling, image ROI and auto function ROI settings refer to the scaled rows and columns of the modified image and not to the physical rows and columns of the sensor.

For example, assume that you are using a camera with a 3 840 x 2 748 sensor. A scaling factor of 0.5 is applied to full resolution. In this case, the maximum ROI width is 1918 and the maximum ROI height is 1372. The ROI width and height parameters are adjusted automatically. Likewise, any offsets that you have defined before enabling scaling are adjusted automatically.

When scaling is disabled, the ROI increases again, but may be smaller than the original ROI.

Basler recommends that you always check the image ROI settings after disabling scaling and, if necessary, to manually restore the image ROI to the desired size and position.

Reduced Resolution

Using scaling effectively reduces the resolution of the camera's imaging sensor. For example, if you are configuring a scaling factor of 0.25 on a camera with a 3 840 x 2 748 sensor, the effective resolution of the camera is reduced to 954 x 682.

Rounding Losses

During scaling, the image dimensions are rounded frequently. If you change the scaling factor repeatedly, the rounding effects accumulate. When returning to a previous image size, the dimensions that were lost due to rounding can't be restored.

To avoid cumulative rounding losses, restore the previous image size manually. Alternatively, return to a "reference" image size, e.g., to full resolution, and specify the image size manually to avoid rounding errors.

Sample Code

// Set horizontal scaling to 0.5
camera.ScalingHorizontalAbs.SetValue(0.5);
// Disable scaling
camera.ScalingHorizontalAbs.SetValue(1);
// Set horizontal scaling to 0.5
camera.ScalingHorizontal.SetValue(0.5);
// Disable scaling
camera.ScalingHorizontal.SetValue(1);
INodeMap& nodemap = camera.GetNodeMap();
// Set horizontal scaling to 0.5
CFloatPtr(nodemap.GetNode("ScalingHorizontalAbs"))->SetValue(0.5);
// Disable scaling
CIntegerPtr(nodemap.GetNode("ScalingHorizontalAbs"))->SetValue(1);
// Set horizontal scaling to 0.5
CFloatPtr(nodemap.GetNode("ScalingHorizontal"))->SetValue(0.5);
// Disable scaling
CIntegerPtr(nodemap.GetNode("ScalingHorizontal"))->SetValue(1);
// Set horizontal scaling to 0.5
camera.Parameters[PLCamera.ScalingHorizontalAbs].SetValue(0.5);
// Disable scaling
camera.Parameters[PLCamera.ScalingHorizontalAbs].SetValue(1);
// Set horizontal scaling to 0.5
camera.Parameters[PLCamera.ScalingHorizontal].SetValue(0.5);
// Disable scaling
camera.Parameters[PLCamera.ScalingHorizontal].SetValue(1);
// Set horizontal scaling to 0.5
Pylon.DeviceSetFloatFeature(hdev, "ScalingHorizontalAbs", 0.5);
// Disable scaling
Pylon.DeviceSetIntegerFeature(hdev, "ScalingHorizontalAbs", 1);
// Set horizontal scaling to 0.5
Pylon.DeviceSetFloatFeature(hdev, "ScalingHorizontal", 0.5);
// Disable scaling
Pylon.DeviceSetIntegerFeature(hdev, "ScalingHorizontal", 1);
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK;  /* Return value of pylon methods */
/* Set horizontal scaling to 0.5 */
errRes = PylonDeviceSetFloatFeature(hdev, "ScalingHorizontalAbs", 0.5);
CHECK(errRes);
/* Disable scaling */
errRes = PylonDeviceSetIntegerFeature(hdev, "ScalingHorizontalAbs", 1);
CHECK(errRes);
/* Set horizontal scaling to 0.5 */
errRes = PylonDeviceSetFloatFeature(hdev, "ScalingHorizontal", 0.5);
CHECK(errRes);
/* Disable scaling */
errRes = PylonDeviceSetIntegerFeature(hdev, "ScalingHorizontal", 1);
CHECK(errRes);

You can also use the pylon Viewer to easily set the parameters.