Resize Batch with Bilinear Interpolation#

Changes a size of images in the batch using the linear interpolation method.

Description

This function changes size of the batch of images using the linear interpolation method. The images size may be either reduced or increased in each direction, depending on the destination images size. The linear interpolation algorithm must use source images intensities at the four pixels in the neighborhood of the point in the source image. The weighted values of these pixels must be used for the destination image. Algorithm parameters must be set through the resize_bilinear_spec class. The border pixels are processed in accordance with the border type. This function can operate with ROI (see Image Regions of Interest). All images in the destination batch shall have the same ROI size.

Headers

oneapi/ipl/transform/resize_bilinear_batch.hpp

Syntax

template<typename ComputeT = float, typename SrcBatchT, typename DstBatchT>
sycl::event oneapi::ipl::resize_bilinear_batch(sycl::queue &queue, SrcBatchT &src, DstBatchT &dst, const resize_bilinear_spec &spec = {}, const std::vector<sycl::event> &dependencies = {})#

Resize Bilinear Batch.

Template Parameters:
  • ComputeT – type to perform calculations

  • SrcBatchT – Source batch type

  • DstBatchT – Destination batch type

Parameters:
  • queue[in] SYCL queue

  • src[in] source batch

  • dst[out] destination batch

  • spec[in] algorithmic specification

  • dependencies[in] other events dependencies

Returns:

SYCL event, that represents a status of an operation it associated with

Supported values for ComputeT:

float

double

half

Supported combinations for DataT/Layouts:

DataT/Layouts

plane

channel3

channel4

plane3

std::uint8_t

std::int8_t

std::uint16_t

std::int16_t

std::uint32_t

std::int32_t

float

double

Supported values for subsampled layout (only for std::uint8_t data type):

:align: center :header: sub420,**sub420i**#

Parameters

border type support

Type of border. Possible values are:

repl - Border is replicated from the edge pixels.

For resize_bilinear_spec description please refer to Resize with Bilinear Interpolation.

Errors

compile-time memory layout check

Indicates an error when image memory layout is not supported.

compile-time data type check

Indicates an error when image data type is not supported.

compile-time compute data type check

Indicates an error when compute data type is not supported.

invalid_argument exception

Indicates an error when source and destination batch sizes are not equal.

unimplemented exception

Indicates an error when border type is not supported.

The code example below demonstrates how oneapi::ipl::resize_bilinear_batch shall be called:

using namespace oneapi;
using descriptor_t = ipl::image_descriptor<ipl::layouts::plane, std::uint8_t>;

sycl::queue queue;

// Allocate and fill grayscale image descriptors memory
auto src_descriptors = sycl::malloc_shared<descriptor_t>(batch_size, queue);
auto dst_descriptors = sycl::malloc_shared<descriptor_t>(batch_size, queue);

auto src_data = sycl::malloc_shared<std::uint8_t>(batch_size * image_size.size(), queue);
auto dst_data = sycl::malloc_shared<std::uint8_t>(batch_size * image_size.size(), queue);

// Here goes filling souce images data

// Fill image descriptors data
for (std::size_t i{ 0U }; i < batch_size; ++i) {
    src_descriptors[i] = descriptor_t{ src_data + i * image_size.size(), width, image_size, { image_size } };
    dst_descriptors[i] = descriptor_t{ dst_data + i * image_size.size(), width, image_size, { image_size } };
}

// Source grayscale batch data
ipl::batch<ipl::layouts::plane, std::uint8_t> src_batch{ src_descriptors, batch_size, image_size };
// Desination grayscale batch data
ipl::batch<ipl::layouts::plane, std::uint8_t> dst_batch{ dst_descriptors, batch_size, image_size };

// Resizes the batch of images.
auto event = ipl::resize_bilinear_batch(queue, src_batch, dst_batch);