The OpenVX Specification  r28647
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Scale Image

Detailed Description

Implements the Image Resizing Kernel.

Performs a Gaussian Blur on an image then half-scales it.

This kernel resizes an image from the source to the destination dimensions. The only format supported is VX_DF_IMAGE_U8. 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 vx_interpolation_type_e, 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 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. More...
 
vx_node vxScaleImageNode (vx_graph graph, vx_image src, vx_image dst, vx_enum type)
 [Graph] Creates a Scale Image Node. More...
 
vx_status vxuHalfScaleGaussian (vx_context context, vx_image input, vx_image output, vx_int32 kernel_size)
 [Immediate] Performs a Gaussian Blur on an image then half-scales it. More...
 
vx_status vxuScaleImage (vx_context context, vx_image src, vx_image dst, vx_enum type)
 [Immediate] Scales an input image to an output image. More...
 

Function Documentation

vx_node 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.
[in]srcThe source image.
[out]dstThe destination image.
[in]typeThe interpolation type to use.
See also
vx_interpolation_type_e.
Note
The destination image must have a defined size and format. Only VX_NODE_ATTRIBUTE_BORDER_MODE value VX_BORDER_MODE_UNDEFINED, VX_BORDER_MODE_REPLICATE or VX_BORDER_MODE_CONSTANT is supported.
Returns
vx_node.
Return values
0Node could not be created.
*Node handle.
vx_node 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 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.
[in]inputThe input VX_DF_IMAGE_U8 image.
[out]outputThe output VX_DF_IMAGE_U8 image.
[in]kernel_sizeThe input size of the Gaussian filter. Supported values are 3 and 5.
Returns
vx_node.
Return values
0Node could not be created.
*Node handle.
vx_status vxuScaleImage ( vx_context  context,
vx_image  src,
vx_image  dst,
vx_enum  type 
)

[Immediate] Scales an input image to an output image.

Parameters
[in]contextThe reference to the overall context.
[in]srcThe source image.
[out]dstThe destintation image.
[in]typeThe interpolation type.
See also
vx_interpolation_type_e.
Returns
A vx_status_e enumeration.
Return values
VX_SUCCESSSuccess
*An error occurred. See vx_status_e.
vx_status vxuHalfScaleGaussian ( vx_context  context,
vx_image  input,
vx_image  output,
vx_int32  kernel_size 
)

[Immediate] Performs a Gaussian Blur on an image then half-scales it.

Parameters
[in]contextThe reference to the overall context.
[in]inputThe input VX_DF_IMAGE_U8 image.
[out]outputThe output VX_DF_IMAGE_U8 image.
[in]kernel_sizeThe input size of the Gaussian filter. Supported values are 3 and 5.
Returns
A vx_status_e enumeration.
Return values
VX_SUCCESSSuccess
*An error occurred. See vx_status_e.