Normalization
Normalization#
Normalization of an image.
Description
This function applies a normalization operation to the source image with the specified subtrahend and divisor with vector size corresponding to the number of image channels. Algorithm to compute kernel is described by formula below:
where
d is divisor
s is subtrahend
Ii,j is image pixel
INi,j is normalized image pixel
Headers
oneapi/ipl/misc/normalize.hpp
Syntax
-
template<typename ComputeT = float, typename SrcImageT, typename DstImageT>
sycl::event oneapi::ipl::normalize(sycl::queue &queue, SrcImageT &src, DstImageT &dst, const normalize_spec_t<SrcImageT::layout_v, ComputeT> &spec, const std::vector<sycl::event> &dependencies = {})# Normalize image.
Uses a normalization with 2 arguments from spec parameter - sub and div: data[i] = (data[i] - sub) / div
- Template Parameters
ComputeT – The type in which all calculations will be performed
SrcImageT – Source image type
DstImageT – Destination image type
- Parameters
queue – SYCL queue
src – source image
dst – destination image
spec – algorithm parameters
dependencies – dependencies
- Returns
SYCL event
Supported values for ComputeT:
float |
double |
half |
---|---|---|
v |
v |
x |
Supported combinations for Data types/Layouts:
Data types/Layouts |
plane |
channel3 |
channel4 |
plane3 |
---|---|---|---|---|
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 layout (only for std::uint8_t
data type):
sub420 |
sub420i |
---|---|
x |
x |
Parameters
-
template<int NumChannels, typename ComputeT = float>
class normalize_spec# Normalize parameters.
Uses a normalization with 2 arguments - sub and div: data[i] = (data[i] - sub) / div If the sub is normalized then the order of operations is inversed data[i] = data[i] / div - sub
- Template Parameters
NumChannels – number of channels
ComputeT – the type for computations
Public Types
-
using pixel_t = sycl::vec<ComputeT, NumChannels>#
Type alias for pixel value type.
Public Functions
-
normalize_spec(const pixel_t &sub, const pixel_t &div)#
Construct Normalize specification based on parameters.
- Parameters
sub – subtrahend of normalization
div – divisor of normalization
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. |
|
Indicates an error when ROI sizes of the source image and the destination image are not equal. |
|
Indicates an error when one of the pitch values is not divisible by size of component data type in bytes. |
The code example below demonstrates how shall be called
oneapi::ipl::normalize
:
using namespace oneapi;
sycl::queue queue;
ipl::shared_usm_allocator_t allocator{ queue };
const sycl::range<2> image_size{ height, width };
// Source 4-channel image data
ipl::image<ipl::layouts::channel4, std::uint8_t> src_image{ queue, p_image_data, image_size, allocator };
// Destination 4-channel image data
ipl::image<ipl::layouts::channel4, float> dst_image{ image_size, allocator };
sycl::float4 sub{ 127.0f };
sycl::float4 div{ 255.0f };
const ipl::normalize_spec norm_spec{ sub, div };
// Normalize image using p' = (p - 127) / 255
auto event = ipl::normalize(queue, src_image, dst_image, norm_spec);