Usage of LBP class from bob.ip.base

53 views
Skip to first unread message

mariana bento

unread,
May 23, 2016, 10:17:02 AM5/23/16
to bob-devel

Hello,


I want to extract the local binary patters from 3D images on python, and found that bob API presents a LBP class, but the input image must be 2D. However, this class presents as one of the input parameters the number of neighbors (that might be 4,8 or 16). My question is: how a 16-neighbood is defined on 2d images? Is it possible to use LBPTop to computed a LBP from a 3d image?


Thanks in advance.

André Anjos

unread,
May 23, 2016, 10:22:45 AM5/23/16
to bob-...@googlegroups.com
Hello,

16-point LBP (last image): https://en.wikipedia.org/wiki/Local_binary_patterns#/media/File:Lbp_neighbors.svg

LBP-TOP on 3D images: I guess so, but I'll Tiago (the original implementor), to answer on how to do this one. The documentation seems a bit outdated.

André

--
Dr. André Anjos
Idiap Research Institute
Centre du Parc - rue Marconi 19
CH-1920 Martigny, Suisse
Phone: +41 27 721 7763
Fax: +41 27 721 7712
http://andreanjos.org

Tiago Freitas Pereira

unread,
May 24, 2016, 3:26:51 AM5/24/16
to bob-...@googlegroups.com
Hi Mariana,

The LBP for 3d images implemented on Bob, was based on this paper (http://www.ee.oulu.fi/mvg/files/pdf/pdf_740.pdf), which is called LBP-Top (Three Orthogonal Planes).
The main motivation of this approach is to extend the LBP operator in the time domain.
In the task that you are trying to solve, what is the third dimension? Is it time dimension or z?

Indeed the documentation is not very clear about the usage.

Follow bellow a piece of code that extracts the LBPs in the three planes for a random 3d image.
I'm adding this code in our official documentation.

```
import bob.ip.base
import numpy
numpy.random.seed(10)

#defining the lbp operator for each plane
lbp_xy = bob.ip.base.LBP(8,1)
lbp_xt = bob.ip.base.LBP(8,1)
lbp_yt = bob.ip.base.LBP(8,1)
lbptop = bob.ip.base.LBPTop(lbp_xy, lbp_xt, lbp_yt)

#defining the 3d image
img3d = (numpy.random.rand(3,5,5)*100).astype('uint16')

#Defining dimensions for each direction
t = int(max(lbp_xt.radius, lbp_yt.radius))
w = int(img3d.shape[1] - lbp_xy.radii[0]*2)
h = int(img3d.shape[2] - lbp_xy.radii[1]*2)

#Output for each plane
output_xy = numpy.zeros((t,w,h),dtype='uint16')
output_xt = numpy.zeros((t,w,h),dtype='uint16')
output_yt = numpy.zeros((t,w,h),dtype='uint16')

#Extracting the bins for each plane
lbptop(img3d,output_xy, output_xt, output_yt)
print(output_xy)
print(output_xt)
print(output_yt)

```


Cheers



--
-- You received this message because you are subscribed to the Google Groups bob-devel group. To post to this group, send email to bob-...@googlegroups.com. To unsubscribe from this group, send email to bob-devel+...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/bob-devel or directly the project website at http://idiap.github.com/bob/
---
You received this message because you are subscribed to the Google Groups "bob-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bob-devel+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Tiago

Tiago Freitas Pereira

unread,
May 24, 2016, 4:28:17 AM5/24/16
to bob-...@googlegroups.com
This example is now in our documentation

http://pythonhosted.org/bob.ip.base/guide.html
--
Tiago

mariana bento

unread,
May 24, 2016, 9:09:53 AM5/24/16
to bob-...@googlegroups.com
Dear Tiago,

Thank you for this explanation.. In my example, the third dimension is z, not time dimension..

I will try it anyways.

Thanks again. M.

You received this message because you are subscribed to a topic in the Google Groups "bob-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bob-devel/z93Dyj7Yysc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bob-devel+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Mariana Leite
Ph.D Candidate
School of Electrical and Computer Engineering
University of Campinas
Reply all
Reply to author
Forward
0 new messages