Resize with Bicubic Interpolation

Changes an image size using interpolation with two-parameter cubic filters.

Description

This function changes an image size using interpolation with two-parameter cubic filters. The image size may be either reduced or increased in each direction, depending on the destination image size. This method must use source image intensities at sixteen pixels in the neighborhood of the point in the source image. Cubic filter parameters must be set through the resize_bicubic_spec class. The border pixels are processed in accordance with the border type. This function can operate with ROI (see Image Regions of Interest).

Headers

oneapi/ipl/transform/resize_bicubic.hpp

Syntax

template<typename ComputeT = float, formats Format, typename DataT, typename SrcAllocatorT, typename DstAllocatorT>
sycl::event oneapi::ipl::resize_bicubic(sycl::queue &queue, image<Format, DataT, SrcAllocatorT> &src, image<Format, DataT, DstAllocatorT> &dst, const resize_bicubic_spec<ComputeT> &spec = {}, const std::vector<sycl::event> &dependencies = {})

Resize with the Bicubic interpolation method.

Template Parameters
  • ComputeT – type to perform calculations

  • Format – source/destination image format

  • DataT – source/destination image data type

  • SrcAllocatorT – source image allocator

  • DstAllocatorT – destination image allocator

Parameters
  • queue[in] SYCL queue

  • src[in] source image

  • dst[out] destination image

  • 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

v

v

x

Supported combinations for DataT/Formats:

DataT/Formats

plane

rgb/bgr

rgba/bgra

rgbp

std::uint8_t

v

v

v

x

std::int8_t

v

v

v

x

std::uint16_t

v

v

v

x

std::int16_t

v

v

v

x

std::uint32_t

v

v

v

x

std::int32_t

v

v

v

x

float

v

v

v

x

double

v

v

v

x

Supported values for subsampled Format (only for DataT = std::uint8_t):

nv12

i420

v

v

Parameters

border type support

Type of border. Possible values are:

repl - Border is replicated from the edge pixels.

bicubic filter parameters support

b and c factors. Possible values are:

b_factor = 0, c_factor = 0.5 - Catmull-Rome spline.

template<typename ComputeT = float>
class oneapi::ipl::resize_bicubic_spec : public oneapi::ipl::border_spec_base<>

Bicubic resize parameters.

Template Parameters

ComputeT – the type for computations

Public Types

using border_spec_base_t = border_spec_base<>

Type alias for base class of spec with border parameters.

using native_pixel_t = sycl::vec<std::uint8_t, 1>

Type alias for pixel type.

Public Functions

resize_bicubic_spec() = default

Construct bicubic resize specification with default values for Cumull-Rom ( \(b=0\), \(c=0.5\)) spline.

explicit resize_bicubic_spec(ComputeT b_factor, ComputeT c_factor, border_types border = border_types::repl, crop_types crop = crop_types::on)

Construct bicubic resize specification.

Parameters
  • b_factor – b factor of bicubic filter

  • c_factor – c factor of bicubic filter

  • border – border type

  • crop – crop flag

template<typename OtherComputeT>
resize_bicubic_spec(const resize_bicubic_spec<OtherComputeT> &other)

Conversion constructor for bicubic resize specification.

Template Parameters

OtherComputeT – the other type for computations

Parameters

other – the other bicubic resize specification

explicit resize_bicubic_spec(border_types border, crop_types crop = crop_types::on)

Construct bicubic resize specification from border type and crop flag.

Parameters
  • border – border type

  • crop – crop flag

ComputeT get_b_factor() const noexcept

Returns the b factor of bicubic filter.

Returns

the b factor of bicubic filter

ComputeT get_c_factor() const noexcept

Returns the c factor of bicubic filter.

Returns

the c factor of bicubic filter

crop_types get_crop() const noexcept

Returns the crop type.

Returns

crop type

border_types get_border() const noexcept

Returns the border type.

Returns

border type

auto get_border_val() const noexcept -> const native_pixel_t&

Returns the border value.

Returns

border value

auto get_border_val_ptr() const -> const std::uint8_t*

Returns the border value pointer.

Returns

border value pointer

Errors

compile-time format check

Indicates an error when image format 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 one of the pitch values is not divisible by size of component data type in bytes.

unimplemented exception

Indicates an error when border type is not supported.

unimplemented exception

Indicates an error when bicubic filter factors are not supported.

The code example below demonstrates how to use the oneapi::ipl::resize_bicubic:

// Create queue
sycl::queue queue{};

// Source rgba image data (image_image)
image<formats::rgba, std::uint8_t> src_image{ src_data_pointer, src_size };
// Destination rgba image data (image_image)
image<formats::rgba, std::uint8_t> dst_image{ dst_size };

(void)resize_bicubic(queue, src_image, dst_image);