imopv.h File Reference
Vectorized image operations. More...
#include "generic.h"
Defines | |
Image convolution flags | |
#define | VL_PAD_BY_ZERO (0x0 << 0) |
Pad with zeroes. | |
#define | VL_PAD_BY_CONTINUITY (0x1 << 0) |
Pad by continuity. | |
#define | VL_PAD_MASK (0x3) |
Padding field selector. | |
#define | VL_TRANSPOSE (0x1 << 2) |
Transpose result. | |
Functions | |
Image convolution | |
void | vl_imconvcol_vf (float *dst, int dst_stride, float const *src, int src_width, int src_height, int src_stride, float const *filt, int filt_begin, int filt_end, int step, unsigned int flags) |
void | vl_imconvcol_vd (double *dst, int dst_stride, double const *src, int src_width, int src_height, int src_stride, double const *filt, int filt_begin, int filt_end, int step, unsigned int flags) |
Convolve image along columns. | |
void | vl_imconvcoltri_f (float *dest, vl_size destStride, float const *image, vl_size imageWidth, vl_size imageHeight, vl_size imageStride, vl_size filterSize, vl_size step, int unsigned flags) |
Convolve an image along the columns with a triangular kernel. | |
void | vl_imconvcoltri_d (double *dest, vl_size destStride, double const *image, vl_size imageWidth, vl_size imageHeight, vl_size imageStride, vl_size filterSize, vl_size step, int unsigned flags) |
Convolve an image along the columns with a triangular kernel. | |
Integral image | |
void | vl_imintegral_f (float *integral, vl_size integralStride, float const *image, vl_size imageWidth, vl_size imageHeight, vl_size imageStride) |
Compute integral image. | |
void | vl_imintegral_d (double *integral, vl_size integralStride, double const *image, vl_size imageWidth, vl_size imageHeight, vl_size imageStride) |
Compute integral image. | |
void | vl_imintegral_i32 (vl_int32 *integral, vl_size integralStride, vl_int32 const *image, vl_size imageWidth, vl_size imageHeight, vl_size imageStride) |
Compute integral image. | |
void | vl_imintegral_ui32 (vl_uint32 *integral, vl_size integralStride, vl_uint32 const *image, vl_size imageWidth, vl_size imageHeight, vl_size imageStride) |
Compute integral image. | |
Distance transform | |
void | vl_image_distance_transform_d (double const *image, vl_size numColumns, vl_size numRows, vl_size columnStride, vl_size rowStride, double *distanceTransform, vl_uindex *indexes, double coeff, double offset) |
void | vl_image_distance_transform_f (float const *image, vl_size numColumns, vl_size numRows, vl_size columnStride, vl_size rowStride, float *distanceTransform, vl_uindex *indexes, float coeff, float offset) |
Detailed Description
This module provides the following image operations:
- Separable convolution. The function vl_imconvcol_vf() can be used to compute separable convolutions.
- Convolution by a triangular kernel. The function vl_imconvcoltri_vf() is an optimized convolution routine for triangular kernels.
- Distance transform. vl_image_distance_transform_f() is a linear algorithm to compute the distance transform of an image.
- Remarks:
- Some operations are optimized to exploit possible SIMD instructions. This requires image data to be properly aligned (typically to 16 bytes). Similalry, the image stride (the number of bytes to skip to move to the next image row), must be aligned.
Function Documentation
void vl_image_distance_transform_d | ( | double const * | image, |
vl_size | numColumns, | ||
vl_size | numRows, | ||
vl_size | columnStride, | ||
vl_size | rowStride, | ||
double * | distanceTransform, | ||
vl_uindex * | indexes, | ||
double | coeff, | ||
double | offset | ||
) |
vl_imconvcol_vd | ( | double * | dst, |
int | dst_stride, | ||
double const * | src, | ||
int | src_width, | ||
int | src_height, | ||
int | src_stride, | ||
double const * | filt, | ||
int | filt_begin, | ||
int | filt_end, | ||
int | step, | ||
unsigned int | flags | ||
) |
- Parameters:
-
dst destination image. dst_stride width of the destination image including padding. src source image. src_width width of the source image. src_height height of the source image. src_stride width of the source image including padding. filt filter kernel. filt_begin coordinate of the first filter element. filt_end coordinate of the last filter element. step sub-sampling step. flags operation modes.
The function convolves the column of the image src by the filter filt and saves the result to the image dst. The size of dst must be equal to the size of src. Formally, this results in the calculation
The function subsamples the image along the columns according to the parameter step. Setting step to 1 (one) computes the elements for all pairs (x,0), (x,1), (x,2) and so on. Setting step two 2 (two) computes only (x,0), (x,2) and so on (in this case the height of the destination image is
floor(src_height/step)+1)
.
Calling twice the function can be used to compute 2-D separable convolutions. Use the flag VL_TRANSPOSE to transpose the result (in this case dst has transposed dimension as well).
The function allows the support of the filter to be any range. Usually the support is filt_end = -filt_begin
.
The convolution operation may pick up values outside the image boundary. To cope with this edge cases, the function either pads the image by zero (VL_PAD_BY_ZERO) or with the values at the boundary (VL_PAD_BY_CONTINUITY).
vl_imconvcol_vf | ( | float * | dst, |
int | dst_stride, | ||
float const * | src, | ||
int | src_width, | ||
int | src_height, | ||
int | src_stride, | ||
float const * | filt, | ||
int | filt_begin, | ||
int | filt_end, | ||
int | step, | ||
unsigned int | flags | ||
) |
- See also:
- vl_imconvcol_vf()
vl_imconvcoltri_d | ( | double * | dest, |
vl_size | destStride, | ||
double const * | image, | ||
vl_size | imageWidth, | ||
vl_size | imageHeight, | ||
vl_size | imageStride, | ||
vl_size | filterSize, | ||
vl_size | step, | ||
int unsigned | flags | ||
) |
- Parameters:
-
dest destination image. destStride destination image stride. image image to convolve. imageWidth width of the image. imageHeight height of the image. imageStride width of the image including padding. filterSize size of the triangular filter. step sub-sampling step. flags operation modes.
The function convolves the columns of the image image with the triangular kernel
The paramter , equal to the function argument filterSize, controls the width of the kernel. Notice that the support of
as a continuous function of
is the open interval
, which has length
. However,
restricted to the ingeter domain
has support
, which counts
elements only. In particular, the discrete kernel is symmetric about the origin for all values of
.
The normalization factor guaratnees that the filter is normalized to one, i.e.:
- Algorithm
The function exploits the fact that convolution by a triangular kernel can be expressed as the repeated convolution by a rectangular kernel, and that the latter can be performed in time indepenedent on the fiter width by using an integral-image type trick. Overall, the algorithm complexity is independent on the parameter filterSize and linear in the nubmer of image pixels.
- See also:
- vl_imconvcol_vd for details on the meaning of the other parameters.
vl_imconvcoltri_f | ( | float * | dest, |
vl_size | destStride, | ||
float const * | image, | ||
vl_size | imageWidth, | ||
vl_size | imageHeight, | ||
vl_size | imageStride, | ||
vl_size | filterSize, | ||
vl_size | step, | ||
int unsigned | flags | ||
) |
- See also:
- vl_imconvcoltri_d()
vl_imintegral_d | ( | double * | integral, |
vl_size | integralStride, | ||
double const * | image, | ||
vl_size | imageWidth, | ||
vl_size | imageHeight, | ||
vl_size | imageStride | ||
) |
- Parameters:
-
integral integral image. integralStride integral image stride. image source image. imageWidth source image width. imageHeight source image height. imageStride source image stride.
Let . The function computes the integral image
of
:
The integral image can be used to compute quickly the integral of of
in a rectangular region
:
Note that the order of operations is important when the integral image has an unsigned data type (e.g. vl_uint32). The formula is easily derived as follows:
vl_imintegral_f | ( | float * | integral, |
vl_size | integralStride, | ||
float const * | image, | ||
vl_size | imageWidth, | ||
vl_size | imageHeight, | ||
vl_size | imageStride | ||
) |
- See also:
- vl_imintegral_d.
vl_imintegral_i32 | ( | vl_int32 * | integral, |
vl_size | integralStride, | ||
vl_int32 const * | image, | ||
vl_size | imageWidth, | ||
vl_size | imageHeight, | ||
vl_size | imageStride | ||
) |
- See also:
- vl_imintegral_d.