Discussion:
Dimensionality of LBP histograms
Somtirtha Roy
2013-06-02 17:29:28 UTC
Permalink
Hi,

I am a Master's student in computer vision and I am using your mahotas
library to extract features for my research.

I am finding it difficult to understand how you are coming up with the
condensed version of the LBP histogram features.
The method that I know selects patterns which has less than or equal to 2
transitions in the bit code. So for a 8-bit code we have 2 patterns for no
transitions, 14 for one transition, 42 for 2 transitions and a bin for all
other transitions. This makes the histogram of dimension 59. But I cant
match this with the mahotas code.

It would be nice if you could give me some explanation regarding the
algorithm you have used as it is important for me to understand the
dimensionality of the histograms.

My results on some experiments were:

(radius,pixels) histogram dimension
================================

(2,2) 3
(2,3) 4
(2,4) 6
(2,5) 8
(2,6) 14
(2,7) 20
(2,8) 36
(2,10) 108
(2,12) 352


Thanks a lot in advance,
--
You received this message because you are subscribed to the Google Groups "pythonvision" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonvision+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Luis Pedro Coelho
2013-06-02 18:58:26 UTC
Permalink
Hi,

I think the code in mahotas is a bit naïve, but the algorithm is to map
each value to a canonical rotation.

The examples below are for 8 bits.

Shift a bit left with wrap-around:

def shift1(x):
lo = 0x1 & x
x >>= 1
x |= (lo << 7)
return x

This just rotates the bits.

To get the canonical representation of each value, we rotate it around
and select the minimal value (this is arbitrary, just needs to have all
map to the same):

def min_shift(x):
values = []
for _ in xrange(8):
values.append(x)
x = shift1(x)
return np.min(values)


If we count the number of canonical values:

print len(set([min_shift(x) for x in xrange(256)]))


it prints 36.

HTH
Luis
Post by Somtirtha Roy
Hi,
I am a Master's student in computer vision and I am using your mahotas
library to extract features for my research.
I am finding it difficult to understand how you are coming up with the
condensed version of the LBP histogram features.
The method that I know selects patterns which has less than or equal to
2 transitions in the bit code. So for a 8-bit code we have 2 patterns
for no transitions, 14 for one transition, 42 for 2 transitions and a
bin for all other transitions. This makes the histogram of dimension 59.
But I cant match this with the mahotas code.
It would be nice if you could give me some explanation regarding the
algorithm you have used as it is important for me to understand the
dimensionality of the histograms.
(radius,pixels) histogram dimension
================================
(2,2) 3
(2,3) 4
(2,4) 6
(2,5) 8
(2,6) 14
(2,7) 20
(2,8) 36
(2,10) 108
(2,12) 352
Thanks a lot in advance,
--
You received this message because you are subscribed to the Google
Groups "pythonvision" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/groups/opt_out.
--
Luis Pedro Coelho | EMBL | http://luispedro.org
--
You received this message because you are subscribed to the Google Groups "pythonvision" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonvision+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Somtirtha Roy
2013-06-05 06:05:15 UTC
Permalink
Hi Luis,

I really appreciate your response. It helped me a lot. Your algorithm is by
the way really interesting as it gives us rotation invariant LBP features,
something to think about.

Thanks,
Post by Luis Pedro Coelho
Hi,
I think the code in mahotas is a bit naïve, but the algorithm is to map
each value to a canonical rotation.
The examples below are for 8 bits.
lo = 0x1 & x
x >>= 1
x |= (lo << 7)
return x
This just rotates the bits.
To get the canonical representation of each value, we rotate it around
and select the minimal value (this is arbitrary, just needs to have all
values = []
values.append(x)
x = shift1(x)
return np.min(values)
print len(set([min_shift(x) for x in xrange(256)]))
it prints 36.
HTH
Luis
Post by Somtirtha Roy
Hi,
I am a Master's student in computer vision and I am using your mahotas
library to extract features for my research.
I am finding it difficult to understand how you are coming up with the
condensed version of the LBP histogram features.
The method that I know selects patterns which has less than or equal to
2 transitions in the bit code. So for a 8-bit code we have 2 patterns
for no transitions, 14 for one transition, 42 for 2 transitions and a
bin for all other transitions. This makes the histogram of dimension 59.
But I cant match this with the mahotas code.
It would be nice if you could give me some explanation regarding the
algorithm you have used as it is important for me to understand the
dimensionality of the histograms.
(radius,pixels) histogram dimension
================================
(2,2) 3
(2,3) 4
(2,4) 6
(2,5) 8
(2,6) 14
(2,7) 20
(2,8) 36
(2,10) 108
(2,12) 352
Thanks a lot in advance,
--
You received this message because you are subscribed to the Google
Groups "pythonvision" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/groups/opt_out.
--
Luis Pedro Coelho | EMBL | http://luispedro.org
--
You received this message because you are subscribed to the Google Groups "pythonvision" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonvision+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...