Crop
File:
/src/image.hppLines 825–899 /**
* @brief Crops 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 |
* | *********!****************************************************************-- |
* | ! |
* | ! |
* | ! |
* | ! |
* | ! |
* --------------------------------------------------------------------------------------------------------
* \_______ ________/
* \/
* core_array::coreDim * 4
*
*
* Figure: Crop area with top-left corner aligned
* --------------------------------------------------------------------------------------------------------
* | TopLeftCorner:(xTopLeft, yTopLeft) |
* | \ ! |
* | \|<-----------------------Width of sub region---------------------------->| |
* | **************************************************************************-- |
* | * * ^ |
* | * * | |
* | * * | |
* | * * | |
* | * * | |
* | * Crop Area * Height |
* | * * of sub |
* | * * region |
* | * * |
* | * * | |
* | * * | |
* | * * | |
* | * * v |
* | **************************************************************************-- |
* | ! |
* | ! |
* | ! |
* | ! |
* | ! |
* --------------------------------------------------------------------------------------------------------
* \_______ ________/
* \/
* core_array::coreDim * 4
* ```
*
* @tparam DdrInTensor Input DDR tensor shape.
* @tparam DdrOutTensor Output DDR tensor shape.
* @param ddrInp Pointer to input DDR tensor.
* @param xTopLeft x coordinate of top left corner of crop area.
* @param yTopLeft y coordinate of top left corner of crop area.
* @param ddrOut Pointer to output DDR tensor.
*/
template <typename DdrInTensor, typename DdrOutTensor>
INLINE void crop(DdrInTensor& ddrInp, std::uint32_t xTopLeft, std::uint32_t yTopLeft, DdrOutTensor& ddrOut) {
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.
File:
/src/image.hppLines 2796–2825 /**
* @brief Resize 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)`.
*
* @tparam resizeMethod Selection of resize method.
* @tparam coordinateTransform Selection of coordinate transform method.
* @tparam convertMethod Color conversion method used is `ColorConversionMethod::NO_CONVERSION`.
* @tparam OcmAllocatorType Type of ocm allocator.
* @tparam OcmInputImageShape The shape of the input image.
* @tparam OcmOutputImageShape The shape of the output image.
* @param ocmInputImage The input image tensor.
* @param ocmOutputImage The output image tensor.
* @param ocmMemAlloc ocm allocator to be used locally.
* @return void
*/
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()) {