This class implements functions interpolating frames and image content.
More...
|
static bool | resize (Frame &frame, const unsigned int width, const unsigned int height, const ResizeMethod resizeMethod=RM_AUTOMATIC, Worker *worker=nullptr) |
| Resizes/rescales a given frame by application of a specified interpolation method. More...
|
|
static bool | resize (const Frame &source, Frame &target, const ResizeMethod resizeMethod=RM_AUTOMATIC, Worker *worker=nullptr) |
| Resizes/rescales a given frame by application of a specified interpolation method. More...
|
|
template<typename T , unsigned int tChannels, ResizeMethod tResizeMethod = RM_AUTOMATIC> |
static bool | resize (const T *source, T *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr) |
| Resizes/rescales a given 1-plane frame by application of a specified interpolation method. More...
|
|
static bool | affine (const Frame &input, Frame &output, const SquareMatrix3 &input_A_output, const InterpolationMethod interpolationMethod=IM_BILINEAR, const uint8_t *borderColor=nullptr, Worker *worker=nullptr, const PixelPositionI &outputOrigin=PixelPositionI(0, 0)) |
| Applies an affine transformation to an image (with zipped pixel format). More...
|
|
static bool | homography (const Frame &input, Frame &output, const SquareMatrix3 &input_H_output, const InterpolationMethod interpolationMethod=IM_BILINEAR, const uint8_t *borderColor=nullptr, Worker *worker=nullptr, const PixelPositionI &outputOrigin=PixelPositionI(0, 0)) |
| Transforms a given input frame (with zipped pixel format) into an output frame (with arbitrary frame dimension) by application of a homography. More...
|
|
|
template<typename T , unsigned int tChannels> |
static bool | resize (const T *source, T *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const ResizeMethod resizeMethod, Worker *worker=nullptr) |
| Resizes/rescales a given 1-plane frame by application of a specified interpolation method. More...
|
|
This class implements functions interpolating frames and image content.
In general, this class is just a thin wrapper around the actual implementation based on the desired interpolation method.
Please be aware that all non-template-based functions of this class are intended for prototyping only.
Binary size can increase significantly when using non-template-based functions as the wrapper will add binary size of every interpolation method.
Thus, in case binary size matters, use the template-based functions directly.
For more details and a visual comparisons of the available image resizing methods see https://facebookresearch.github.io/ocean/docs/images/resizing/
- See also
- FrameInterpolatorBilinear, FrameInterpolatorNearestPixel.
◆ InterpolationMethod
Definition of individual interpolation methods.
Enumerator |
---|
IM_INVALID | An invalid interpolation method.
|
IM_NEAREST_PIXEL | An interpolation applying a nearest pixel (nearest neighbor) lookup.
|
IM_BILINEAR | An interpolation applying a bilinear interpolation.
|
◆ ResizeMethod
Definition of individual resize methods.
Commonly, higher enum values will create better image qualities, while also will need more computational time.
Enumerator |
---|
RM_INVALID | An invalid resize method.
|
RM_NEAREST_PIXEL | An interpolation applying a nearest pixel (nearest neighbor) lookup.
|
RM_BILINEAR | An interpolation applying a bilinear interpolation.
|
RM_NEAREST_PYRAMID_LAYER_11_BILINEAR | A two-step interpolation, first applying a pyramid down sampling with a 11 filtering, followed by bilinear interpolation from pyramid layer to target image.
|
RM_NEAREST_PYRAMID_LAYER_14641_BILINEAR | A two-step interpolation, first applying a pyramid down sampling with a 14641 filtering, followed by bilinear interpolation from pyramid layer to target image.
|
RM_AUTOMATIC | The resize method with best quality/performance ratio providing high image qualities with good performance values.
|
◆ affine()
Applies an affine transformation to an image (with zipped pixel format).
The output frame must have the same pixel format and pixel origin as the input frame, however the dimension (and position) of the output frame can be arbitrary.
This function allows the creation of an output frame fully covering the input frame (if the position and dimension of the output frame covers the transformation of the affine transformation.
The multiplication of the affine transformation with pixel location in the output image yield their location in the input image, i.e., inputPoint = affineTransform * outputPoint.
The parameter 'outputOrigin' applies an additional translation to the provided affine transformation i.e., input_A_output * create_translation_matrix3x3(outputOrigin.x(), outputOrigin.y()).
Please note that here the affine transformation is specified as a 3-by-3 matrix (in contrast to the more commonly used 2-by-3 matrix) and should take of the form:
Rxx Ryx Tx
Rxy Ryy Ty
0 0 1
However, this function disregards the last row completely and only uses the top two rows, i.e., the elements a through f. Information: This function is the equivalent to OpenCV's cv::warpAffine().
Note: For applications running on mobile devices, in order to keep the impact on binary size to a minimum please prefer a specialized transformation function (those that work on image pointers instead of Frame instances).
- Parameters
-
input | The input frame that will be transformed, must be valid |
output | The resulting frame after applying the affine transformation to the input frame; pixel format and pixel origin must be identical to input frame; memory of output frame must be allocated by the caller |
input_A_output | The affine transform used to transform the given input frame, transforming points defined in the output frame into points defined in the input frame |
interpolationMethod | The interpolation method to be used, must be either IM_BILINEAR or IM_NEAREST_PIXEL |
borderColor | Color of undefined pixel positions, the size of the buffer must match to the number of channels, nullptr to assign 0x00 to each channel |
worker | Optional worker object to distribute the computational load |
outputOrigin | The origin of the output frame defining the global position of the output frame's pixel coordinate (0, 0), with range (-infinity, infinity)x(-infinity, infinity) |
- Returns
- True, if succeeded
◆ homography()
Transforms a given input frame (with zipped pixel format) into an output frame (with arbitrary frame dimension) by application of a homography.
The output frame must have the same pixel format and pixel origin as the input frame, however the dimension (and position) of the output frame can be arbitrary.
This function allows the creation of an output frame fully covering the input frame (if the position and dimension of the output frame covers the transformation of the homography.
The homography given defines the transformation of output pixels to input pixels (inputPoint = homography * outputPoint).
The 'outputOrigin' parameter simply applies an additional translation onto the provided homography i.e., homography * create_translation_matrix3x3(outputOrigin.x(), outputOrigin.y()).
Information: This function is the equivalent to OpenCV's cv::warpPerspective().
- Parameters
-
input | The input frame that will be transformed, must be valid |
output | The output frame resulting by application of the given homography, with same pixel format and pixel origin as the input frame, must be valid |
input_H_output | The homography used to transform the given input frame, transforming points defined in the output frame into points defined in the input frame |
interpolationMethod | The interpolation method to be used, must be either IM_BILINEAR or IM_NEAREST_PIXEL |
borderColor | Color of undefined pixel positions, the size of the buffer must match to the number of channels, nullptr to assign 0x00 to each channel |
worker | Optional worker object to distribute the computational load |
outputOrigin | The origin of the output frame defining the global position of the output frame's pixel coordinate (0, 0), with range (-infinity, infinity)x(-infinity, infinity) |
- Returns
- True, if succeeded
◆ resize() [1/4]
Resizes/rescales a given frame by application of a specified interpolation method.
- Parameters
-
source | The source frame to resize, must not have a packed pixel format, must be valid |
target | Resulting target frame with identical frame pixel format and pixel origin as the source frame, must be valid |
resizeMethod | The resize method to be used |
worker | Optional worker object used for load distribution, must be valid |
- Returns
- True, if the frame could be resized
- See also
- FrameType::formatIsPacked().
◆ resize() [2/4]
template<typename T , unsigned int tChannels>
static bool Ocean::CV::FrameInterpolator::resize |
( |
const T * |
source, |
|
|
T * |
target, |
|
|
const unsigned int |
sourceWidth, |
|
|
const unsigned int |
sourceHeight, |
|
|
const unsigned int |
targetWidth, |
|
|
const unsigned int |
targetHeight, |
|
|
const unsigned int |
sourcePaddingElements, |
|
|
const unsigned int |
targetPaddingElements, |
|
|
const ResizeMethod |
resizeMethod, |
|
|
Worker * |
worker = nullptr |
|
) |
| |
|
staticprotected |
Resizes/rescales a given 1-plane frame by application of a specified interpolation method.
This template-based implementation ensures that the binary impact is as small as possible.
- Parameters
-
source | The source frame buffer to resize, must be valid |
target | The target frame buffer, must be valid |
sourceWidth | Width of the source frame in pixel, with range [1, infinity) |
sourceHeight | Height of the source frame in pixel, with range [1, infinity) |
targetWidth | Width of the target frame in pixel, with range [1, infinity) |
targetHeight | Height of the target frame in pixel, with range [1, infinity) |
sourcePaddingElements | Optional padding at the end of each source row in elements, with range [0, infinity) |
targetPaddingElements | Optional padding at the end of each target row in elements, with range [0, infinity) |
resizeMethod | The resize method to be used |
worker | Optional worker object used for load distribution |
- Returns
- True, if the frame could be resized
- Template Parameters
-
T | Data type of each pixel channel, e.g., 'uint8_t', 'float' |
tChannels | Number of channels of the frame, with range [1, infinity) |
◆ resize() [3/4]
template<typename T , unsigned int tChannels, FrameInterpolator::ResizeMethod tResizeMethod>
bool Ocean::CV::FrameInterpolator::resize |
( |
const T * |
source, |
|
|
T * |
target, |
|
|
const unsigned int |
sourceWidth, |
|
|
const unsigned int |
sourceHeight, |
|
|
const unsigned int |
targetWidth, |
|
|
const unsigned int |
targetHeight, |
|
|
const unsigned int |
sourcePaddingElements, |
|
|
const unsigned int |
targetPaddingElements, |
|
|
Worker * |
worker = nullptr |
|
) |
| |
|
static |
Resizes/rescales a given 1-plane frame by application of a specified interpolation method.
This template-based implementation ensures that the binary impact is as small as possible.
- Parameters
-
source | The source frame buffer to resize, must be valid |
target | The target frame buffer, must be valid |
sourceWidth | Width of the source frame in pixel, with range [1, infinity) |
sourceHeight | Height of the source frame in pixel, with range [1, infinity) |
targetWidth | Width of the target frame in pixel, with range [1, infinity) |
targetHeight | Height of the target frame in pixel, with range [1, infinity) |
sourcePaddingElements | Optional padding at the end of each source row in elements, with range [0, infinity) |
targetPaddingElements | Optional padding at the end of each target row in elements, with range [0, infinity) |
worker | Optional worker object used for load distribution |
- Returns
- True, if the frame could be resized
- Template Parameters
-
T | Data type of each pixel channel, e.g., 'uint8_t', 'float' |
tChannels | Number of channels of the frame, with range [1, infinity) |
tResizeMethod | The resize method to be used |
◆ resize() [4/4]
static bool Ocean::CV::FrameInterpolator::resize |
( |
Frame & |
frame, |
|
|
const unsigned int |
width, |
|
|
const unsigned int |
height, |
|
|
const ResizeMethod |
resizeMethod = RM_AUTOMATIC , |
|
|
Worker * |
worker = nullptr |
|
) |
| |
|
static |
Resizes/rescales a given frame by application of a specified interpolation method.
- Parameters
-
frame | The frame to resize, must not have a packed pixel format, must be valid |
width | The width of the resized frame in pixel, with range [1, infinity) |
height | The height of the resized frame in pixel, with range [1, infinity) |
resizeMethod | The resize method to be used |
worker | Optional worker object used for load distribution, must be valid |
- Returns
- True, if the frame could be resized
- See also
- FrameType::formatIsPacked().
The documentation for this class was generated from the following file: