This section includes information for using the C or C++ API of bob::ip::gabor. The pure C++ API of the classes in bob::ip::gabor can be obtained through including the specific header files, which will be described below, e.g.:
#include <bob.ip.gabor/Wavelet.h>
On the other hand, to leverage from the pure C API, you simply need to include:
#include <bob.ip.gabor/api.h>
The classes and functions in the C++ API are all contained in the bob::ip::gabor namespace. All classes from the Python API are reflected in the C++ API as well. Particularly:
Implements the Gabor wavelet in C++, which is defined in frequency domain as:
(1)
Constructor taking the image resolution, the wavelet frequency
, the width of the enveloping Gaussian
and the
value power_of_k.
When dct_free is set to false, the second part of (1) will not be added.
For efficiency reasons, the Gabor wavelet is not implemented as an image, but wavelet values that are lower than the given epsilon are discarded.
Computes and returns an image containing the Gabor wavelet in frequency domain.
Performs the Gabor wavelet transform with a single Gabor wavelet on the given frequency_domain_image and writes it’s result into the transformed_frequency_domain_image. Note that both images are of complex type and considered to be in frequency domain.
Implements a family of Gabor wavelets used to perform a Gabor wavelet transform.
Gabor wavelets are extracted for a given number of scales and directions, which will result in several
vectors for the (1):
(2)
with:
(3)
Constructor taking the number_of_scales
, the number_of_orientations
, the k_max
and the k_fac
as given in (3).
The parameters sigma, pow_of_k, dc_free and epsilon are directly passed to the Wavelet constructor.
Note
The Gabor wavelets are not generated in this constructor since the image resolution is not known at construction time. The wavelets will only be generated during a call to transform() or to generateWavelets().
Computes a Gabor wavelet transform on the given image, which can be of various types T. If needed, this function will automatically call generateWavelets() with the current image resolution. The resulting trafo_image must have the shape (numberOfWavelets(), grap_image.extent(0), grap_image.extent(1)).
Generates the family of Gabor wavelets for the given image resolution.
Returns the list of frequencies
as defined in (2) for all wavelets stored in this family.
Provides the list of Wavelets which are stored in this class.
Note
This list will be empty until either of transform() or generateWavelets() is called.
Returns the number of wavelets of this Gabor wavelet family, i.e.,
.
Loads the configuration of this Gabor wavelet family from the given bob::io::base::HDF5File.
Note
No wavelets are created in after loading the configuration.
Saves the configuration of this Gabor wavelet family to the given bob::io::base::HDF5File.
An implementation of a Gabor jet, which is a local texture descriptor by collecting all wavelet responses of a given Transform object. Gabor jets store the wavelet responses in polar form, i.e., storing the absolute values abs() and the phases phase(). In this implementation, the Gabor phases are always extracted, and by default, the vector of absolute values of the Gabor jets is normalized to unit Euclidean length.
Default constructor that generates an uninitialized Gabor jet of the given length
Extracts a Gabor jet at the given location from the trafo_image, which usually is a result of the Transform::transform() function.
Creates a Gabor jet from the given vector of complex-valued data.
Creates a Gabor jet by averaging the given Gabor jets, which need to be of the same length.
Normalizes the absolute values of the Gabor jet to unit Euclidean length and return its old Euclidean length.
Returns the absolute and phase values of this Gabor jet, where jet()(0,.) contains the absolute values, while jet()(1,.) comprises the phases.
Returns the absolute values of this Gabor jet, i.e., jet() (0).
Returns the phase values of this Gabor jet, i.e., jet() (1).
Returns a complex-valued representation of the Gabor jet, which is computed on the fly.
Returns the length of this Gabor jet, which is usually the number of wavelets Transform::numberOfWavelets(), i.e.,
.
Loads the Gabor jet from the given bob::io::base::HDF5File.
Saves the Gabor jet to the given bob::io::base::HDF5File.
Implements several Gabor jet similarity functions, which will compute the similarity of two Jets. Currently, several types are implemented, see the documentation for the Python class bob.ip.gabor.Jet for a list of implemented functions.
Enumeration to define the type of the similarity function to be computed.
Constructor to create a Gabor jet similarity function of the given SimilarityType. Some types of similarity functions require the Transform with which the Jets are extracted.
Computes the similarity of the two Gabor jets using.
Estimates the disparity vector between the given two Gabor jets. For some similarity functions, the disparity() is computed and stored.
Returns the disparity vector estimated in the last call to similarity().
Note
Not all similarity function compute the disparity. Hence, the returned values might be NaN.
Shifts the Jet::phase() values of the jet towards the reference such that the disparity(shifted, reference) == (0., 0.).
Loads the configuration of this Gabor jet similarity from the given bob::io::base::HDF5File.
Saves the configuration of this Gabor jet similarity to the given bob::io::base::HDF5File.
Extracts several Gabor jets from a given image using a fixed set of locations, which usually form a grid.
Generates a grid graph extractor which is aligned to the given eye positions. When the eye positions are not on a horizontal line, the grid will be slanted. In the graph, there will be between nodes placed in between the eye positions, along nodes to the left and to the right of the eyes, above nodes above the eyes and below nodes below the eyes. Hence, in total (2*along + between + 2) X (above + below + 1) nodes will be created.
Generates a grid graph extractor which will extract regular grid graphs. The first node is extracted at the given first position, the next nodes will be placed step pixels further (where horizontal and vertical steps are handled independently), and the last node is placed at or before the given last node.
Constructs a graph extractor using the given nodes.
Extracts Gabor jets from the given trafo_image (which is usually the result of a call to Transform::transform(). The extracted Gabor jets will be placed into the given jets vector, which might be empty or contain Gabor jets, which will be updated.
Replaces the nodes of this graph with the given ones.
Returns the node positions of this graph.
Loads the configuration of this graph extractor from the given bob::io::base::HDF5File.
Saves the configuration of this graph extractor to the given bob::io::base::HDF5File.
The C-API can be used in the Python bindings, when you need to reference a C++ class of the bob::ip::gabor namespace. When you use the C++ API in a derived package Python bindings, please make sure that you import this package, as well as the dependencies bob.blitz, bob.io.base and bob.sp, by adding the following lines to your module definition:
#include <bob.blitz/capi.h>
#include <bob.io.base/api.h>
#include <bob.sp/api.h>
#include <bob.ip.gabor/api.h>
PyMODINIT_FUNC initclient(void) {
...
/* imports dependencies */
if (import_bob_blitz() < 0) {
PyErr_Print();
PyErr_SetString(PyExc_ImportError, "cannot import extension");
return 0;
}
if (import_bob_io_base() < 0) {
PyErr_Print();
PyErr_SetString(PyExc_ImportError, "cannot import extension");
return 0;
}
if (import_bob_sp() < 0) {
PyErr_Print();
PyErr_SetString(PyExc_ImportError, "cannot import extension");
return 0;
}
if (import_bob_ip_gabor() < 0) {
PyErr_Print();
PyErr_SetString(PyExc_ImportError, "cannot import extension");
return 0;
}
...
}
For each of the five classes above, there exist three objects that can be used in the bindings. These objects are defined in the api.h header file:
The shared pointer to object of the underlying bob::ip::gabor::Wavelet class.
The PyTypeObject that defines the bob::ip::gabor::Wavelet class.
The function to check if the given PyObject is castable to a PyBobIpGaborWaveletObject. It returns 1 if it is, and 0 otherwise.
The shared pointer to object of the underlying bob::ip::gabor::Transform class.
The PyTypeObject that defines the bob::ip::gabor::Transform class.
The function to check if the given PyObject is castable to a PyBobIpGaborTransformObject. It returns 1 if it is, and 0 otherwise.
The shared pointer to object of the underlying bob::ip::gabor::Jet class.
The PyTypeObject that defines the bob::ip::gabor::Jet class.
The function to check if the given PyObject is castable to a PyBobIpGaborJetObject. It returns 1 if it is, and 0 otherwise.
The shared pointer to object of the underlying bob::ip::gabor::Similarity class.
The PyTypeObject that defines the bob::ip::gabor::Similarity class.
The function to check if the given PyObject is castable to a PyBobIpGaborSimilarityObject. It returns 1 if it is, and 0 otherwise.
The shared pointer to object of the underlying bob::ip::gabor::Graph class.
The PyTypeObject that defines the bob::ip::gabor::Graph class.
The function to check if the given PyObject is castable to a PyBobIpGaborGraphObject. It returns 1 if it is, and 0 otherwise.