Crop
cropfunction
File:
/src/image.hppLines 905–989Crops a sub-section of an image. Crop coordinates can be specified at runtime.
Figure: Crop area with top-left corner unaligned
--------------------------------------------------------------------------------------------------------
TopLeftCorner:(xTopLeft, yTopLeft) |
| \ ! |
| \|<-----------------------Width of sub region---------------------------->| |
| *********!****************************************************************-- |
| * ! * ^ |
| * ! * | |
| * ! * | |
| * ! * | |
| * ! * | |
| * ! Crop Area * Height |
| * ! * of sub |
| * ! * region |
| * ! * |
| * ! * | |
| * ! * | |
| * ! * | |
| * ! * v |
| *********!****************************************************************-- |
| ! |
| ! |
| ! |
| ! |
| ! |
--------------------------------------------------------------------------------------------------------template <typename DdrInTensor, typename DdrOutTensor>
INLINE void crop(DdrInTensor& ddrInp,
std::uint32_t xTopLeft,
std::uint32_t yTopLeft,
DdrOutTensor& ddrOut)Template Parameters
| Name | Type | Default | Description |
|---|---|---|---|
DdrInTensor | typename | Input DDR tensor shape. | |
DdrOutTensor | typename | Output DDR tensor shape. |
Parameters
| Name | Type | Description |
|---|---|---|
ddrInp | DdrInTensor& | Pointer to input DDR tensor. |
xTopLeft | std::uint32_t | x coordinate of top left corner of crop area. |
yTopLeft | std::uint32_t | y coordinate of top left corner of crop area. |
ddrOut | DdrOutTensor& | Pointer to output DDR tensor. |
Returns
INLINE void
Resize
For the general-purpose tensor resize API (chimera::image::resize, including DDR/multicore variants), see Image Resize. The overload below resizes 3-channel planar images with optional fused color conversion.
resizeImagefunction
File:
/src/image.hppLines 2857–2877Resize a 3-channel planar image.
Input tensor shape must be of form (1, channels, height, width). Output tensor shape must be of form (1, channels, resized_height, num_channels).
template <ResizeMethod resizeMethod,
CoordinateTransform coordinateTransform = CoordinateTransform::HALF_PIXEL,
ColorConversionMethod convertMethod = ColorConversionMethod::NO_CONVERSION,
typename OcmAllocatorType = EmptyType,
typename OcmInputImageShape,
typename OcmOutputImageShape,
std::enable_if_t<resizeMethod != ResizeMethod::BILINEAR_INTERPOLATION_MULTISTEP &&
resizeMethod != ResizeMethod::BILINEAR_INTERPOLATION_ASYMMETRIC &&
resizeMethod != ResizeMethod::BILINEAR_INTERPOLATION_HALF_PIXEL, int> = 0>
INLINE void resizeImage(OcmInputImageShape& ocmInputImage,
OcmOutputImageShape& ocmOutputImage,
const OcmAllocatorType& ocmMemAlloc = EmptyType())Template Parameters
| Name | Type | Default | Description |
|---|---|---|---|
resizeMethod | ResizeMethod | Selection of resize method. | |
coordinateTransform | CoordinateTransform | CoordinateTransform::HALF_PIXEL | Selection of coordinate transform method. |
convertMethod | ColorConversionMethod | ColorConversionMethod::NO_CONVERSION | Color conversion method used is `ColorConversionMethod::NO_CONVERSION`. |
OcmAllocatorType | typename | EmptyType | Type of ocm allocator. |
OcmInputImageShape | typename | The shape of the input image. | |
OcmOutputImageShape | typename | The shape of the output image. |
Parameters
| Name | Type | Description |
|---|---|---|
ocmInputImage | OcmInputImageShape& | The input image tensor. |
ocmOutputImage | OcmOutputImageShape& | The output image tensor. |
ocmMemAlloc | const OcmAllocatorType& | ocm allocator to be used locally. |
Returns
INLINE void — void
