Skip to content

zoom_image_factorZoomImageFactorZoomImageFactorzoom_image_factorzoom_image_factor🔗

Short description🔗

zoom_image_factorZoomImageFactorZoomImageFactorzoom_image_factorzoom_image_factor — Zoom an image by a given factor.

Signature🔗

zoom_image_factor( image Image, out image ImageZoomed, extent.x ScaleWidth, extent.y ScaleHeight, string Interpolation )void ZoomImageFactor( const HObject& Image, HObject* ImageZoomed, const HTuple& ScaleWidth, const HTuple& ScaleHeight, const HTuple& Interpolation )static void HOperatorSet.ZoomImageFactor( HObject image, out HObject imageZoomed, HTuple scaleWidth, HTuple scaleHeight, HTuple interpolation )def zoom_image_factor( image: HObject, scale_width: float, scale_height: float, interpolation: str ) -> HObject

Herror zoom_image_factor( const Hobject Image, Hobject* ImageZoomed, double ScaleWidth, double ScaleHeight, const char* Interpolation )

Herror T_zoom_image_factor( const Hobject Image, Hobject* ImageZoomed, const Htuple ScaleWidth, const Htuple ScaleHeight, const Htuple Interpolation )

HImage HImage::ZoomImageFactor( double ScaleWidth, double ScaleHeight, const HString& Interpolation ) const

HImage HImage::ZoomImageFactor( double ScaleWidth, double ScaleHeight, const char* Interpolation ) const

HImage HImage::ZoomImageFactor( double ScaleWidth, double ScaleHeight, const wchar_t* Interpolation ) const (Windows only)

HImage HImage.ZoomImageFactor( double scaleWidth, double scaleHeight, string interpolation )

Description🔗

zoom_image_factorZoomImageFactor scales the image Imageimageimage by a factor of ScaleWidthscaleWidthscale_width in width and a factor ScaleHeightscaleHeightscale_height in height. The parameter Interpolationinterpolationinterpolation determines the type of interpolation used (see affine_trans_imageAffineTransImage). The domain of the input image is ignored, i.e., assumed to be the full rectangle of the image.

Attention🔗

If the system parameter 'int_zooming'"int_zooming" is set to 'true'"true", the internally used integer arithmetic may lead to errors in the following three cases: First, if zoom_image_factorZoomImageFactor is used on an uint2 or int2 image with high dynamics (i.e. images containing values close to the respective limits) in combination with scale factors smaller than \(0.5\), then the gray values of the output image may be erroneous. Second, if Interpolationinterpolationinterpolation is set to a value other than 'nearest_neighbor'"nearest_neighbor", a large scale factor is applied, and a large output image is obtained, then undefined gray values at the lower and at the right image border may result. The maximum width \(B_{max}\) of this border of undefined gray values can be estimated as \(B_{max}=0.5 \cdot S \cdot I / 2^{15}\), where \(S\) is the scale factor in one dimension and \(I\) is the size of the output image in the corresponding dimension. Third, for real images undefined gray values can occur on all image borders, if Interpolationinterpolationinterpolation is set to 'nearest_neighbor'"nearest_neighbor", and if both the input and output image is large. In all cases, it is recommended to set 'int_zooming'"int_zooming" to 'false'"false" via the operator set_systemSetSystem.

If 'nearest_neighbor'"nearest_neighbor" is set as interpolation method the results can differ slightly for different image types. This is due to the usage of image type specific optimizations of the applied interpolation algorithm.

zoom_image_factorZoomImageFactor is not parallelized internally if ScaleWidthscaleWidthscale_width = \(0.5\) and ScaleHeightscaleHeightscale_height = \(0.5\). Further zoom_image_factorZoomImageFactor is not parallelized internally with Interpolationinterpolationinterpolation='nearest_neighbor'"nearest_neighbor".

zoom_image_factorZoomImageFactor can be executed on OpenCL devices if the input image does not exceed the maximum size of image objects of the selected device. Due to numerical reasons, there can be slight differences in the output compared to the execution on the CPU.

Execution information🔗

Execution information
  • Supports OpenCL compute devices.

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

  • Automatically parallelized on channel level.

  • Automatically parallelized on internal data level.

Parameters🔗

Imageimageimage (input_object) (multichannel-)image(-array) → object (byte* / int2* / uint2* / real*)HObject (byte* / int2* / uint2* / real*)HImage (byte* / int2* / uint2* / real*)HObject (byte* / int2* / uint2* / real*)Hobject (byte* / int2* / uint2* / real*) *allowed for compute devices

Input image.

ImageZoomedimageZoomedimage_zoomed (output_object) (multichannel-)image(-array) → object (byte / int2 / uint2 / real)HObject (byte / int2 / uint2 / real)HImage (byte / int2 / uint2 / real)HObject (byte / int2 / uint2 / real)Hobject * (byte / int2 / uint2 / real)

Scaled image.

ScaleWidthscaleWidthscale_width (input_control) extent.x → (real)HTuple (double)HTuple (double)floatHtuple (double)

Scale factor for the width of the image.

Default: 0.50.5
Suggested values: 0.25, 0.5, 1.5, 2.00.25, 0.5, 1.5, 2.0
Value range: 0.001 ≤ ScaleWidth ≤ 10.0
Minimum increment: 0.001
Recommended increment: 0.1

ScaleHeightscaleHeightscale_height (input_control) extent.y → (real)HTuple (double)HTuple (double)floatHtuple (double)

Scale factor for the height of the image.

Default: 0.50.5
Suggested values: 0.25, 0.5, 1.5, 2.00.25, 0.5, 1.5, 2.0
Value range: 0.001 ≤ ScaleHeight ≤ 10.0
Minimum increment: 0.001
Recommended increment: 0.1

Interpolationinterpolationinterpolation (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Type of interpolation.

Default: 'constant'"constant"
List of values: 'bicubic', 'bilinear', 'constant', 'nearest_neighbor', 'weighted'"bicubic", "bilinear", "constant", "nearest_neighbor", "weighted"

Example🔗

(HDevelop)

read_image(Image,'monkey')
dev_display (Image)
zoom_image_factor (Image, ZoomImage, 0.25, 0.25, 'constant')
dev_display (ZoomImage)
(C)
read_image(&Image,"monkey")\;
disp_image(Image,WindowHandle)\;
zoom_image_factor(Image,&ZooImage,0.25,0.25,"constant")\;
disp_image(ZooImage,WindowHandle)\;

Combinations with other operators🔗

Combinations

Alternatives

zoom_image_sizeZoomImageSize, affine_trans_imageAffineTransImage, hom_mat2d_scaleHomMat2dScale

See also

hom_mat2d_scaleHomMat2dScale, affine_trans_imageAffineTransImage

Module🔗

Foundation