Re: Local Binary Patterns - Description

148 views
Skip to first unread message

Luis Pedro Coelho

unread,
May 1, 2013, 3:53:58 PM5/1/13
to python...@googlegroups.com
lbp() returns a histogram of features, so that positions X corresponds
to how many pixels had code X.

HTH
--
Luis Pedro Coelho | EMBL | http://luispedro.org

On 05/01/2013 04:00 PM, Solimyr wrote:
> Hi to everyone!
>
> I'm trying to use the mahotas features to analyze some images. In
> particular I'm using the Local Binary Patterns (LBP).
>
> My idea is to try with image with radius 1 and 8 point and so, a 3x3
> window. So I take a 3x3 window and apply the mahotas lbp. I was
> expecting a vector/histogram of 8 values with just 0 and 1 but, what I
> get, is a 36 vector-size with elements from zero to more than one. I
> don't know if I'm stucked with some old theories of LBP or what.
>
> Why don't I get a 8 vector size with elements from 0 to 1? My idea is
> afterthat, convert in decimal and get the decimal value. Well, I'm
> pretty confused with the result and the theory that I get from internet.
>
> Could you please help me to understand?
>
> Thank you very much for your support!
> Solimyr
>
> --
> 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/groups/opt_out.
>
>

Luis Pedro Coelho

unread,
May 1, 2013, 3:59:31 PM5/1/13
to python...@googlegroups.com
I took this opportunity to better the documentation on the function:

http://mahotas.readthedocs.org/en/latest/lbp.html

(It's nice that Read the docs automatically updates after a github push)

HTH,
Message has been deleted

Solimyr

unread,
May 1, 2013, 5:12:27 PM5/1/13
to python...@googlegroups.com
Thank you for your answer but sorry, it's still not clear to me and of course, you don't have to explain to me anything! It's my fault!

I have my pixel in the middle. Let me say that I'm taking a R=1 and P=8 so it could be represented as 3x3 window, right? 

What I was expecting from the function is something like this (I will try to explain it with an example):

I have this 3x3 window:

                10  13  12
                 8    9   22
                 1    3   5

So, I'm expecting this result:

                 1    1    1
                 0          1        -->  11110000 = 240
                 0    0    0

Using the mahotas.features.lbp(image,1,8), I get:

[2, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

I'm start to thinking that are two different stuff or from the second I could get 240?

I'm sure that is a dummy question so don't worry about answering...

Thank You,
Solimyr

Luis Pedro Coelho

unread,
May 2, 2013, 2:45:15 AM5/2/13
to python...@googlegroups.com
On 05/01/2013 11:12 PM, Solimyr wrote:
> Thank you for your answer but sorry, it's still not clear to me and of
> course, you don't have to explain to me anything! It's my fault!
>
> I have my pixel in the middle. Let me say that I'm taking a R=1 and P=8
> so it could be represented as 3x3 window, right?
>
> What I was expecting from the function is something like this (I will
> try to explain it with an example):
>
> I have this 3x3 window:
>
> 10 13 12
> 8 9 22
> 1 3 5
>
> So, I'm expecting this result:
>
> 1 1 1
> 0 1 --> 11110000 = 240
> 0 0 0

Yes, but that's one pixel, so we'd count it like this:

[0,0,...., 1, 0, 0 ...].

The position of the 1 is the position corresponding to 240. It is not
position 240 because most of the values are unused (00001111 is
equivalent to 11110000 rotionally).

Your image has nine pixels, so you get a histogram which sums to 9.

--
HTH
Luis
> > an email to pythonvision...@googlegroups.com <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.

Solimyr

unread,
May 2, 2013, 10:06:09 AM5/2/13
to python...@googlegroups.com
Thanks, I think that I'm starting to get it (I hope :D).

Yes, but that's one pixel, so we'd count it like this: 

[0,0,...., 1, 0, 0 ...]. 

So I get 240 for that pixel and I'm increasing the frenquency of that value in my histogram. So, when I see on internet image like this:


It's because they just use one pixel to make the new image, right? In mahotas the LBP works with all the pixel in the window, e.g. 3x3 pixel use the 9 pixel, right? Is this correct?

Thank you very much,
Solimyr

Luis Pedro Coelho

unread,
May 3, 2013, 5:41:25 AM5/3/13
to python...@googlegroups.com
On 05/02/2013 04:06 PM, Solimyr wrote:
>
> So I get 240 for that pixel and I'm increasing the frenquency of that
> value in my histogram. So, when I see on internet image like this:
>
> http://www.mathworks.com/matlabcentral/fx_files/37781/2/LBP_face.jpg
>
> It's because they just use one pixel to make the new image, right? In
> mahotas the LBP works with all the pixel in the window, e.g. 3x3 pixel
> use the 9 pixel, right? Is this correct?
>

Ah, that kind of image with each pixel being assigned its LBP value
cannot be computed with mahotas (why would you want it? Serious
question, why would you like to have that image?)

What mahotas computes is the histogram of that image (except that
certain pixel values which are impossible are kept out of the histogram).

Solimyr

unread,
May 3, 2013, 9:30:37 AM5/3/13
to python...@googlegroups.com
Well, to answer your question, my point is that LBP value and conseguently that image, represents in some way a new texture of that image.

K.-Michael Aye

unread,
May 3, 2013, 10:48:52 AM5/3/13
to python...@googlegroups.com


On May 3, 2013, at 6:30, Solimyr <giannic...@msn.com> wrote:

Well, to answer your question, my point is that LBP value and conseguently that image, represents in some way a new texture of that image.

If you want a minimalistic but identifiable representation of your image, maybe you want a Radon transform? I don't know if mahotas has it, but scikit-image has it. 

Michael

Il giorno venerdì 3 maggio 2013 06:41:25 UTC-3, Luis Pedro Coelho ha scritto:
On 05/02/2013 04:06 PM, Solimyr wrote:
>
> So I get 240 for that pixel and I'm increasing the frenquency of that
> value in my histogram. So, when I see on internet image like this:
>
> http://www.mathworks.com/matlabcentral/fx_files/37781/2/LBP_face.jpg
>
> It's because they just use one pixel to make the new image, right? In
> mahotas the LBP works with all the pixel in the window, e.g. 3x3 pixel
> use the 9 pixel, right? Is this correct?
>

Ah, that kind of image with each pixel being assigned its LBP value
cannot be computed with mahotas (why would you want it? Serious
question, why would you like to have that image?)

What mahotas computes is the histogram of that image (except that
certain pixel values which are impossible are kept out of the histogram).

HTH
--
Luis Pedro Coelho | EMBL | http://luispedro.org

--

Solimyr

unread,
May 3, 2013, 11:29:04 AM5/3/13
to python...@googlegroups.com
Don't know what is a Radon transform, I will check it! Thank you!!!

Thanks,
Solimyr

Luis Pedro Coelho

unread,
May 23, 2013, 4:25:05 AM5/23/13
to python...@googlegroups.com, Solimyr
Hi,

I finally understood why this could be useful: in order to build a
pixel-level classifier, you might think it useful.

I just committed support for it:

https://github.com/luispedro/mahotas/commit/d01a02800548beaa03be49a4964812e45808ad2e

HTH
--
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...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>


Solimyr

unread,
May 23, 2013, 8:35:44 AM5/23/13
to python...@googlegroups.com, Solimyr
Eheheheheh, that's what I was trying to say. What does 'I just committed support' mean? My english is awful!!

Luis Pedro Coelho

unread,
May 23, 2013, 8:38:41 AM5/23/13
to python...@googlegroups.com
On 05/23/2013 02:35 PM, Solimyr wrote:
> Eheheheheh, that's what I was trying to say. What does 'I just committed
> support' mean? My english is awful!!

I meant to write

"I just pushed a git commit which includes support for this."

This means that it is available on the github version, but not in any
released version (ATM).

If you get it from https://github.com/luispedro/mahotas, you will get
this functionality.

It also means that it is considered "experimental" and open to changes
(for example, I have already changed the name of one of the parameters
from the initial commit, something I would never ever do if it was a
released version).

HTH
Luis
> > an email to pythonvision...@googlegroups.com <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
Reply all
Reply to author
Forward
0 new messages