chamfer_transform - Computes the chamfer distance transform of a binary edge image.
Example compile flags (system dependent):
-DLINUX_X86_64 -DLINUX_X86_64_OPTERON -DGNU_COMPILER
-lKJB -lfftw3 -lgsl -lgslcblas -ljpeg -lSVM -lstdc++ -lpthread -lSLATEC -lg2c -lacml -lacml_mv -lblas -lg2c -lncursesw
const Matrix *in,
Input is a binary edge image represented as a Matrix, and output is a map of
the distance and location of the nearest edge point in the input image.
The local maxima of the distance map is the voronoi diagram of the edge
points. The size parameter sets the neighborhood size when propagating
distance values; higher value will result in lower approximation error but
increases running time. Valid values for size are 3, 5, or 7.
After returning, distances_out will hold the distance map, and locations_out
will hold two matrices representing the x and y locations of the nearest edge
NO_ERROR on success, and ERROR on failure, with an error message being
As the exact distance transform is expensive to compute, the chamfer distance
transform is a fast approximation. When the voronoi diagram has corners with
very acute angles, the chamfer transform may report the nearest edge point
incorrectly. Also, distances are not computed directly but instead are
propogated from neighboring pixels and are subject to approximation error.
Using higher size values diminshes this effect somewhat. These errors are
generally of little concern, but do be aware of them.
This software is not adequatedly tested. It is recomended that
results are checked independantly where appropriate.