The OpenVX Specification  a73e458
Scale Image

Detailed Description

Implements the Image Resizing Kernel.

This kernel resizes an image from the source to the destination dimensions. The supported interpolation types are currently:

The sample positions used to determine output pixel values are generated by scaling the outside edges of the source image pixels to the outside edges of the destination image pixels. As described in the documentation for Interpolation Constants, samples are taken at pixel centers. This means that, unless the scale is 1:1, the sample position for the top left destination pixel typically does not fall exactly on the top left source pixel but will be generated by interpolation.

That is, the sample positions corresponding in source and destination are defined by the following equations:

\[ x_{input} = \left((x_{output} + 0.5) * \frac{width_{input}}{width_{output}}\right) - 0.5 \]

\[ y_{input} = \left((y_{output} + 0.5) * \frac{height_{input}}{height_{output}}\right) - 0.5 \]

\[ x_{output} = \left((x_{input} + 0.5) * \frac{width_{output}}{width_{input}}\right) - 0.5 \]

\[ y_{output} = \left((y_{input} + 0.5) * \frac{height_{output}}{height_{input}}\right) - 0.5 \]

samplingpatterns.png

The above diagram shows three sampling methods used to shrink a 7x3 image to 3x1.

The topmost image pair shows nearest-neighbor sampling, with crosses on the left image marking the sample positions in the source that are used to generate the output image on the right. As the pixel centre closest to the sample position is white in all cases, the resulting 3x1 image is white.

The middle image pair shows bilinear sampling, with black squares on the left image showing the region in the source being sampled to generate each pixel on the destination image on the right. This sample area is always the size of an input pixel. The outer destination pixels partly sample from the outermost green pixels, so their resulting value is a weighted average of white and green.

The bottom image pair shows area sampling. The black rectangles in the source image on the left show the bounds of the projection of the destination pixels onto the source. The destination pixels on the right are formed by averaging at least those source pixels whose areas are wholly or partly contained within those rectangles. The manner of this averaging is implementation-defined; the example shown here weights the contribution of each source pixel by the amount of that pixel's area contained within the black rectangle.

Functions

vx_node VX_API_CALL vxHalfScaleGaussianNode (vx_graph graph, vx_image input, vx_image output, vx_int32 kernel_size)
 [Graph] Performs a Gaussian Blur on an image then half-scales it. The interpolation mode used is nearest-neighbor. More...
 
vx_node VX_API_CALL vxScaleImageNode (vx_graph graph, vx_image src, vx_image dst, vx_enum type)
 [Graph] Creates a Scale Image Node. More...
 

Function Documentation

◆ vxScaleImageNode()

vx_node VX_API_CALL vxScaleImageNode ( vx_graph  graph,
vx_image  src,
vx_image  dst,
vx_enum  type 
)

[Graph] Creates a Scale Image Node.

Parameters
[in]graphThe reference to the graph [R00183].
[in]srcThe source image of type VX_DF_IMAGE_U8 [R00184].
[out]dstThe destination image of type VX_DF_IMAGE_U8 [R00185].
[in]typeThe interpolation type to use. Use a Interpolation Constants value.
Note
The destination image must have a defined size and format [R00186]. The border modes VX_NODE_BORDER value VX_BORDER_UNDEFINED, VX_BORDER_REPLICATE and VX_BORDER_CONSTANT are supported [R00187].
Returns
vx_node [R00188].
Return values
vx_nodeA node reference. Any possible errors preventing a successful creation should be checked using vxGetStatus

◆ vxHalfScaleGaussianNode()

vx_node VX_API_CALL vxHalfScaleGaussianNode ( vx_graph  graph,
vx_image  input,
vx_image  output,
vx_int32  kernel_size 
)

[Graph] Performs a Gaussian Blur on an image then half-scales it. The interpolation mode used is nearest-neighbor.

The output image size is determined by:

\[ W_{output} = \frac{W_{input} + 1}{2} \\ , H_{output} = \frac{H_{input} + 1}{2} \]

Parameters
[in]graphThe reference to the graph [R00395].
[in]inputThe input VX_DF_IMAGE_U8 image [R00396].
[out]outputThe output VX_DF_IMAGE_U8 image [R00397].
[in]kernel_sizeThe input size of the Gaussian filter. Supported values are 1, 3 and 5 [R00398].
Returns
vx_node [R00399].
Return values
vx_nodeA node reference. Any possible errors preventing a successful creation should be checked using vxGetStatus