Overview
Gaussian pyramid generator takes one input image and fills the output image pyramid with downscaled versions of the input.
Implementation
The function is implemented by generating the Gaussian pyramid from the base (level 0) to coarser levels.
If the input image actually wraps the first level of the image pyramid, nothing is done for this level. If not, the input image contents will be copied to the first image pyramid level.
The coarser levels are generated by taking the previous level, convolving it using a clamp border extension with the following kernel:
\[ k = \begin{bmatrix} 1 \\ 4 \\ 6 \\ 4 \\ 1 \end{bmatrix} \cdot \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \end{bmatrix} \]
Because only 2x downscaling is supported, the result is then downsampled by keeping all pixels with even coordinates.
The algorithm repeats until all levels are generated.
Usage
Language:
C/C++
Python
Import VPI module
Returns the 4-level Gaussian pyramid created from the input image using the CUDA backend. Input is a VPI image, and output is a VPI pyramid. with vpi.Backend.CUDA:
output = input.gaussian_pyramid(4)
Initialization phase
Include the header that defines the Gaussian pyramid generator function.
Declares functions that handle gaussian pyramids.
Define the input image object.
struct VPIImageImpl * VPIImage
A handle to an image.
Create the output pyramid with the desired number of levels (4) and scale factor (0.5). It gets its dimensions and format from the input image. int32_t w, h;
VPIStatus vpiImageGetFormat(VPIImage img, VPIImageFormat *format)
Get the image format.
VPIStatus vpiImageGetSize(VPIImage img, int32_t *width, int32_t *height)
Get the image size in pixels.
struct VPIPyramidImpl * VPIPyramid
A handle to an image pyramid.
VPIStatus vpiPyramidCreate(int32_t width, int32_t height, VPIImageFormat fmt, int32_t numLevels, float scale, uint32_t flags, VPIPyramid *pyr)
Create an empty image pyramid instance with the specified flags.
Create the stream where the algorithm will be submitted for execution.
struct VPIStreamImpl * VPIStream
A handle to a stream.
VPIStatus vpiStreamCreate(uint32_t flags, VPIStream *stream)
Create a stream instance.
Processing phase
Submit the algorithm to the stream, along with the input image and output pyramid. It'll be executed by the CPU backend.
VPIStatus vpiSubmitGaussianPyramidGenerator(VPIStream stream, uint32_t backend, VPIImage input, VPIPyramid output)
Computes the Gaussian pyramid from the input image.
@ VPI_BACKEND_CPU
CPU backend.
Optionally, wait until the processing is done.
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
Cleanup phase
Free resources held by the stream, the input image and the output pyramid.
void vpiImageDestroy(VPIImage img)
Destroy an image instance.
void vpiPyramidDestroy(VPIPyramid pyr)
Destroy an image pyramid instance as well as all resources it owns.
void vpiStreamDestroy(VPIStream stream)
Destroy a stream instance and deallocate all HW resources.
For more information, see Gaussian Pyramid Generator in the "API Reference" section of VPI - Vision Programming Interface .
Limitations and Constraints
Constraints for specific backends supersede the ones specified for all backends.
All Backends
Input image and output pyramid must have the same image type
Input image and pyramid's base level must have same dimensions
Only scale=0.5 is supported (i.e. only dyadic pyramids can be generated)
The following image formats are accepted:
PVA
Only available on Jetson Xavier devices.
Every pyramid level's dimension must be at least 65x65 big.
The following image formats are the only ones accepted:
Pyramid must have at most 10 levels.
VIC
Performance
For information on how to use the performance table below, see Algorithm Performance Tables .
Before comparing measurements, consult Comparing Algorithm Elapsed Times .
For further information on how performance was benchmarked, see Performance Benchmark .
clear filters
Device:
Jetson AGX Xavier
Jetson TX2
Jetson Nano
-
Streams:
1
4
8