Commit 3ebf336a authored by Manuel Günther's avatar Manuel Günther

Corrected bug in the order of LBPTop radii.

parent c2b551fa
......@@ -27,23 +27,18 @@ bob::ip::base::LBPTop::LBPTop(
{
/*
* Checking the inputs. The radius in XY,XT and YT must be the same
* Note: radii are in opposity direction lbp_xy has radii stored in (y,x), aso.
*/
if(lbp_xy->getRadii()[0]!=lbp_xt->getRadii()[0]) {
boost::format m("the radii R_xy[0] (%f) and R_xt[0] (%f) do not match");
m % lbp_xy->getRadii()[0] % lbp_xt->getRadii()[0];
throw std::runtime_error(m.str());
if(lbp_xy->getRadii()[1]!=lbp_xt->getRadii()[1]) {
throw std::runtime_error((boost::format("The X radii of R_xy (%f) and R_xt (%f) do not match")% lbp_xy->getRadii()[1] % lbp_xt->getRadii()[1]).str());
}
if(lbp_xy->getRadii()[1]!=lbp_yt->getRadii()[0]) {
boost::format m("the radii R_xy[1] (%f) and R_yt[0] (%f) do not match");
m % lbp_xy->getRadii()[1] % lbp_yt->getRadii()[0];
throw std::runtime_error(m.str());
if(lbp_xy->getRadii()[0]!=lbp_yt->getRadii()[1]) {
throw std::runtime_error((boost::format("The Y radii R_xy (%f) and R_yt (%f) do not match")% lbp_xy->getRadii()[0] % lbp_yt->getRadii()[1]).str());
}
if(lbp_xt->getRadii()[1]!=lbp_yt->getRadii()[0]) {
boost::format m("the radii R_xt[1] (%f) and R_yt[0] (%f) do not match");
m % lbp_xt->getRadii()[1] % lbp_yt->getRadii()[0];
throw std::runtime_error(m.str());
if(lbp_xt->getRadii()[0]!=lbp_yt->getRadii()[0]) {
throw std::runtime_error((boost::format("The T radii R_xt (%f) and R_yt (%f) do not match")% lbp_xt->getRadii()[0] % lbp_yt->getRadii()[0]).str());
}
}
......@@ -63,4 +58,3 @@ bob::ip::base::LBPTop& bob::ip::base::LBPTop::operator= (const LBPTop& other) {
m_lbp_yt = other.m_lbp_yt;
return *this;
}
......@@ -141,9 +141,9 @@ namespace bob { namespace ip { namespace base {
blitz::Array<uint16_t,3>& yt
) const
{
int radius_x = m_lbp_xy->getRadii()[0]; ///< The LBPu2,i radius in X direction
int radius_y = m_lbp_xy->getRadii()[1]; ///< The LBPu2,i radius in Y direction
int radius_t = m_lbp_yt->getRadii()[1]; ///< The LBPu2,i radius in T direction
int radius_x = m_lbp_xy->getRadii()[1]; ///< The LBPu2,i radius in X direction
int radius_y = m_lbp_xy->getRadii()[0]; ///< The LBPu2,i radius in Y direction
int radius_t = m_lbp_yt->getRadii()[0]; ///< The LBPu2,i radius in T direction
int Tlength = src.extent(0);
int height = src.extent(1);
......
......@@ -27,8 +27,13 @@ static auto LBPTop_doc = bob::extension::ClassDoc(
).add_constructor(
bob::extension::FunctionDoc(
"__init__",
"Constructs a new LBPTop object starting from the algorithm configuration",
0,
"Constructs a new LBPTop object",
"For all three directions, the LBP objects need to be specified. "
"The radii for the three LBP classes must be consistent, i.e., ``xy.radii[1] == xt.radii[1]``, ``xy.radii[0] == yt.radii[1]`` and ``xt.radii[0] == yt.radii[0]``.\n\n"
".. warning::\n\n"
" The order of the ``radius_x`` and ``radius_y`` parameters are not ``(radius_x, radius_y)`` in the :py:class:`LBP` constructor, but ``(radius_y, radius_x)``. "
" Hence, to get an ``x`` radius 2 and ``y`` radius 3, you need to use ``xy = bob.ip.base.LBP(8, 3, 2)`` or more specifically ``xy = bob.ip.base.LBP(8, radius_x=2, radius_y=3)``. "
" The same applies for ``xt`` and ``yt``.",
true
)
.add_prototype("xy, xt, yt", "")
......
......@@ -745,6 +745,30 @@ def test_vanilla_4p1r_4p1r_4p1r():
nose.tools.eq_(proc2(values_5x5,plane_index=2,operator_coordinates=(0,0,0)),0x7)
def test_lpb_top_with_radii():
# XY with rx = 4 and ry = 6
lbp_xy = bob.ip.base.LBP(8, 6., 4.)
# XT with rx = 4 and rt = 2
lbp_xt = bob.ip.base.LBP(8, 2., 4.)
# YT with ry = 6 and rt = 2
lbp_yt = bob.ip.base.LBP(8, 2., 6.)
assert lbp_xy.radii[1] == lbp_xt.radii[1]
assert lbp_xy.radii[0] == lbp_yt.radii[1]
assert lbp_xt.radii[0] == lbp_yt.radii[0]
# the correct order shouldn't raise
op = bob.ip.base.LBPTop(lbp_xy, lbp_xt, lbp_yt)
# all other orders should raise
with nose.tools.assert_raises(RuntimeError) as exc:
op = bob.ip.base.LBPTop(lbp_xy, lbp_yt, lbp_xt)
with nose.tools.assert_raises(RuntimeError) as exc:
op = bob.ip.base.LBPTop(lbp_xt, lbp_yt, lbp_xy)
"""
" Test LBPHS feature extraction
"""
......@@ -782,6 +806,3 @@ def test_lbphs():
result = bob.ip.base.lbphs(src, lbp, block_size = (5,5), block_overlap=(0,0))
assert numpy.allclose(result, lbphs)
2.0.4b0
\ No newline at end of file
2.0.4b1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment