LBP histogram dimension??

35 views
Skip to first unread message

Goutham

unread,
May 19, 2015, 1:02:24 PM5/19/15
to python...@googlegroups.com
Why the LBP histogram in mahotas gives 36 bins instead of 59.Sorry,I can't follow the previous post regarding this.Can anybody explain me further?

Luis Pedro Coelho

unread,
May 19, 2015, 3:52:36 PM5/19/15
to python...@googlegroups.com
Hi,

For 8 bit codes, 36 is just what comes out from the rotation invariant
condition.

The rule is that the binary codes are invariant to rotation. One way of
implementing this is to normalize all the codes to the minimal value of
all rotations (this value is called the pivot and aggregates all values
it represents). That is, you take each value, you try all possible
binary rolls and you take the minimal value. So, code 1 will actually
represent 1, 2, 4, 8, 16...; code 3 (0000 0011) will also represent 6
(0000 0110), 12 (0000 1100)...; code 5(000 0101) will also represent 10
(0000 1010)...

Now, we can just count how many of these pivots there are.


For 8 bit codes, a 1 bit roll can be implemented like this:

def roll1(i):
return ((i << 1) & 0xff) + bool(i & 128)

Now, we can check whether a binary value is a pivot using this basic
loop:

def is_min(v):
i = v
for _ in range(8):
i = roll1(i)
if i > v:
return False
return True

Ok, so how many pivots are there?
n_pivots = sum([is_min(i) for i in range(256)])

It's 36.

HTH
--
Luis Pedro Coelho | EMBL | http://luispedro.org
My blog: http://metarabbit.wordpress.com
> --
> 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...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Luis Pedro Coelho

unread,
May 19, 2015, 3:58:50 PM5/19/15
to python...@googlegroups.com
There is a bug in the previous code (the < comparison should have read
>). As written, it uses the maximum as the pivot. Of course, it doesn't
really matter as you end up with the same number of pivots (different
ones, but the same number of equivalent classes).

HTH
--
Luis Pedro Coelho | EMBL | http://luispedro.org
My blog: http://metarabbit.wordpress.com

Goutham

unread,
May 20, 2015, 10:16:28 AM5/20/15
to python...@googlegroups.com
Thanks, :)

Goutham

unread,
May 21, 2015, 1:54:55 PM5/21/15
to python...@googlegroups.com
So the 36 bins corresponds to the 36 pivot values,like 0,1,3,5,7.....127,255..Right??

Luis Pedro Coelho

unread,
May 21, 2015, 2:11:18 PM5/21/15
to python...@googlegroups.com
Yes, exactly.

--
Luis Pedro Coelho | EMBL | http://luispedro.org
My blog: http://metarabbit.wordpress.com

Goutham

unread,
May 22, 2015, 2:41:44 AM5/22/15
to python...@googlegroups.com
Thank you :)

Goutham

unread,
May 22, 2015, 3:39:34 AM5/22/15
to python...@googlegroups.com
For 16 neighbours the histogram bins in mahotas implementation is 4116 instead of 243 !!! I think this implementation take more computing time. !!!


On Thursday, May 21, 2015 at 11:41:18 PM UTC+5:30, Luis Pedro Coelho wrote:
Reply all
Reply to author
Forward
0 new messages