Magnitude#
Computes magnitude of elements of a complex data image.
Description
This function computes magnitude of elements of the source image src given in complex data format, and stores results in the destination image dst. The element-wise magnitude is defined by the formula:
where
\(i,j,k\) are coordinates and color component of the image pixel
\(Re(x)\) is real part of value
\(Im(x)\) is imaginary part of pixel value
Input type must be a complex number type. Output image type will be of the same layout as input type but with a real number output.
Headers
oneapi/ipl/misc/magnitude.hpp
Syntax
-
template<typename ComputeT = float, typename SrcImageT, typename DstImageT>
sycl::event oneapi::ipl::magnitude(sycl::queue &queue, SrcImageT &src, DstImageT &dst, const magnitude_spec &spec = {}, const std::vector<sycl::event> &dependencies = {})# Computes magnitude of elements of a complex data image.
- Template Parameters:
ComputeT – type to perform calculations
SrcImageT – Source image type
DstImageT – Destination image type
- Parameters:
queue – SYCL queue
src – source image
dst – destination image
spec – algorithmic spec
dependencies – list of events to wait for before starting computation, if any. if omitted, defaults to no dependencies.
- Returns:
SYCL event
Supported values for ComputeT:
float |
double |
half |
---|---|---|
✓ |
✓ |
✗ |
Supported combinations for Data types/Layouts:
Supported Input/Output Layouts |
plane |
channel3 |
Supported Input data types |
std::complex<float> |
Supported Output data types |
float |
Parameters
-
class magnitude_spec#
Magnitude parameters.
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
oneapi::ipl::magnitude
shall be called:
using namespace oneapi;
sycl::queue queue;
ipl::shared_usm_allocator_t allocator{ queue };
const sycl::range<2> image_size{ height, width };
// Source 3-channel complex input image
ipl::image<ipl::layouts::channel3, std::complex<float>> src_image{ queue, p_image_data, image_size, allocator };
// Destination float image
ipl::image<ipl::layouts::channel3, float> dst_image{ image_size, allocator };
const ipl::magnitude_spec mag_spec{};
auto event = ipl::magnitude(queue, src_image, dst_image, mag_spec);