Generating C++ Modules
The Command Shell
Pixels and Images
Graphics: plots, profiles
Image file I/O
Creating New Modules
This page describes image operators such as direct convolution of filter masks and images, recursive implementations of Gaussian derivatives, steering of Gaussian derivatives and scale normalisation.
We have two modules for Gaussian derivatives, based on two articles by VanVliet. The old implementation (module modFilter) uses 3 coefficients for the computation and the Abramowitz approximation. Direct formulas are given for derivatives up to order 3. There are significant boundary effects, especially in the upper left corner of the image. Important: you can not trust the values near the border of the image! The boundary effects are strong within a band of width 1.5*sigma pixels around the border of the image. The functions reduce the ROI of the image accordingly. Other major problems: the Laplacian is not sufficiently isotropic and the sigma of the recursive implementation is 1.177 times larger than the sigma of a true Gaussian.
The new implementation (module modTGFilter) uses 3,4 or 5 coefficients. This means that the derivatives are more precise but can take a little longer in computation. The better precision is noted in the higher derivatives. For example the Laplacian is much more round (isotropic) than with the old implementation and the sigma corresponds to the sigma of a true Gaussian. Better approximations are achieved for large sigmas. We have direct formulas for derivatives up to order 2. The 3rd order derivatives are approximated by an additional filtering of the 2nd order. This is ok, since the Gaussian derivatives are separable. It must be noted, that higher orders amplify the error between a direct convolution and the recursive approximation.
For both modules we have implemented automatic scale selection. The intrinsic scale of a feature is noted as a maximum in the Laplacian or Gradient profile. Such a profile is computed by measuring the energy of a Laplacian (or Gradient magnitude) placed at a image position (x,y) and varying over scales. The functions are loaded with the modules.
Author: V. Colin de Verdiere
In the module modFilter we have implemented functions to compute convolutions of filter masks with images. This kind of operation can be very costly, depending on the size of the mask and size of the image. For computing derivatives of images, you should use the recursive Gaussian derivative implementation described below.
Following functions are implemented:
These functions compute the response of a image src to a filter given by filter, either at one point (x,y) or an entire image.
This computes the convolution of src with filter. Same as ImgFilter, but filter is flipped before computation.
These functions compute the convolution only along one axis (X or Y). These functions should always called in pairs.
These functions apply a binomial 121 filter to the image. This is the coarsest approximation of a Gaussian you can find. The gradient is computed by a filter -101.
([VanVliet95]) Authors: V. Colin de Verdiere, O. Chomat
Currently there are functions implemented for derivatives up to order 3, for the gradient and for the Laplacian. These functions are loaded by require modFilter.
compute the Gaussian of an TBitmapFloat image fimg with size sigma. The last arggument is not used. FGR_XY is the first version of the function. FGR_XY2 and FGR_XY3 are more recent implementations.
The procedure names give hints to the content. "d" means derivative. FGR_dX computes the derivative in direction X. There are 3 prototype functions. I would use when possible the FGR_dX2, because this is the currently optimised function.
The derivatives can be called by function
with filterType f noting the order of the derivative.
These functions compute the dominant angle of all (pixelwise) local features in the image. The theory comes from [Freeman91].
This function computes the gradient magnitude of all local features.
This function computes the Laplacian of all local features.
([VanVliet98]) Authors: S. Richetto, D. Hall
Currently there are functions implemented for derivatives up to order 3, for the gradient and for the Laplacian. These functions are loaded by require modTGFilter.
GaussianFilter3, GaussianFilter4, GaussianFilter5 are classes that inherit the functions from the parent class GaussianFilter.
The X in GaussianFilterX corresponds to the number of coefficients used for the computation. The GaussianFilter3 is slightly faster, but less precise than GaussianFilter5.
The constructor sets the sigma of the current object. This sigma can be modified by
The derivative functions are following. Important: these functions compute the derivatives directly without applying a smoothing before. This has the advantage that they can be concatenated to obtain higher order derivatives.
When you want to compute the derivatives of images up to order three use following functions.
We have implemented an analogon to FGR() of recursive filter. This function calls the above functions according to filterType defined in recursiveFilter.
Computes Laplacian, Gradient and Gaussian.
Authors: V. Colin de Verdiere, D. Hall
Gaussian derivatives are steerable. This means that a derivative can be synthetized at arbitrary angle by a linear combination of the derivatives of the same order [Freeman91].
This function orients the first derivative according to the angles in ang_img with an offset of alpha.
These functions do essentially the same for the 2nd order derivative. But we have observed that FGR_d2d orients only dxx. To steer the dxy and dyy use FGR_d2dxy, FGR_d2dyy and for completeness FGR_d2dxx. The correct used linear combinations are :
This function orients the 3rd derivative, but only dxxx. Steering of dxxy, dxyy, dyyy needs to be done!
The steering functions take as argument the filtered images. This means that they can be used with TGFilter. It is sufficient to hand the "tgfiltered" images as arguments to the function.
Author: V. Colin de Verdiere, D. Hall
We have implemented functions that select automatically the smallest intrinsic scale of a Laplacian scale profile, normalise the feature to this scale([Lindeberg98], [Lindeberg98b]). This enables the matching of features invariant to the scale of observation.
This procedure computes the smallest intrinsic scale of all (pixelwise) image features according to the normalised Laplacian scale profile. The scale profile is computed for sigmas
within the range sigma_0 = sinit*pow(sfactor, from), sigma_1 = sinit*pow(sfactor, from+step), ..., sigma_n = sinit*pow(sfactor, min(from + k*step, to)). Important: nb >= to+1, else you risk a segmentation fault.
sigma_img contains the index x of the intrinsic scale. To obtain the true sigma, you need to compute sigma = sinit*pow(sfactor,x). We work with followin parameters:
Once you have obtained the sigma_img, you can extract the normalised local features from any derivative you like. In the theses of Colin de Verdiere, Chomat, and Hall we used the intrinsic scale from the Laplacian profile. The intrinsic scale for edges is particularily unstable. In such cases the intrinsic scale should be computed from the Gardient magnitude ([Chomat00]). But for a first start you can continue to use the Laplacian profile.
For feature extraction call following functions in that order
MultiFilterTG5 generates a (very large) TBitmapFloatVector that contains the fileterd images of all sigmas within the defined range for( int sig=init, sig < final, sig+=freq). SelectOptSigmaTG5 chooses for every pixel the value from deriv_list according to the index marked in sigma_img and places it in dst. Important: to achieve scale invariance, the derivatives must be normalised by sigma^(order of derivative). This means, norm must be set as follows:
Corresponding functions exist for the old implementation of the recursive filters, but due to the problem of the bad approximation of the Laplacian, I suggest to use the above describe functions.