The large file is also due to a missing dimensionality reduction in the implementation, which can be applied for Local Binary Patterns without a great loss of information. If you read up some literature on Local Binary Patterns, you'll notice there is something called Uniform Patterns. This is due to the LBP definition and its a-priori probabilities for building some patterns :
- Francesco Bianconi and Antonio Fernández, "On the occurrence probability of local binary patterns: a theoretical study". Journal of Mathematical Imaging and Vision 01/2011; 40:259-268. (PDF)
The Scholarpedia page on LBP states:
Another extension to the original
operator is the definition of so
called uniform patterns, which can be
used to reduce the length of the
feature vector and implement a simple
rotation-invariant descriptor. This
extension was inspired by the fact
that some binary patterns occur more
commonly in texture images than
others. A local binary pattern is
called uniform if the binary pattern
contains at most two bitwise
transitions from 0 to 1 or vice versa
when the bit pattern is traversed
circularly. For example, the patterns
00000000 (0 transitions), 01110000 (2
transitions) and 11001111 (2
transitions) are uniform whereas the
patterns 11001001 (4 transitions) and
01010010 (6 transitions) are not. In
the computation of the LBP labels,
uniform patterns are used so that
there is a separate label for each
uniform pattern and all the
non-uniform patterns are labeled with
a single label. For example, when
using (8,R) neighborhood, there are a
total of 256 patterns, 58 of which are
uniform, which yields in 59 different
labels.
Ojala et al. (2002) noticed in their
experiments with texture images that
uniform patterns account for a little
less than 90% of all patterns when
using the (8,1) neighborhood and for
around 70% in the (16,2) neighborhood.
Each bin (LBP code) can be regarded as
a micro-texton. Local primitives which
are codified by these bins include
different types of curved edges,
spots, flat areas etc.
It should be easy to add this to the implementation, please open up a ticket with the specific feature request on http://code.opencv.org if you would like to see it implemented.
yml will take much less space/time than xml
alternatively, you could retrieve the histograms after the training, like:
and do your own (binary) serialization