Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Pattern
Pi19404
January 18, 2014
Contents
Contents
Local Binary Pattern
2|8
A LBP
number characterizes the local texture by assigning
the binomial factor 2 for each sign sgn(l
l )
P;R
LBPP;R
lp
LBPP;R
for p = 0 : : : P
of radius R.
1
sgn(lp
lc )2
=0
3|8
4|8
1
2
nclude "ImgFeatures/integralImage.h"
ass LBPFeatures
3
4
5
6
7
8
9
blic:
LBPFeatures(){};
Mat image;
vector<uchar> features;
Mat mask;
IntegralImage ix;
10
11
12
13
14
15
16
17
5|8
int width=image.cols;
int height=image.rows;
18
19
20
for(int i=1;i<height-1;i++)
{
for(int j=0;j<width-1;j++)
{
int center=(int)ptr[j+i*width];
unsigned char code=0;
code|=((int)ptr[(j-1)+(i-1)*width] >=center)<<7 ;
code|=((int)ptr[j+(i-1)*width] >=center)<<6 ;
code|=((int)ptr[(j+1)+(i-1)*width] >=center)<<5 ;
code|=((int)ptr[(j+1)+(i)*width] >=center)<<4 ;
code|=((int)ptr[(j+1)+(i+1)*width] >=center)<<3 ;
code|=((int)ptr[j+(i+1)*width] >=center)<<2 ;
code|=((int)ptr[j-1+(i+1)*width] >=center)<<1 ;
code|=((int)ptr[j-1+(i)*width] >=center)<<0 ;
optr[j+i*width]=code;
}
}
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
6|8
104
105
7|8
111
Mat roi=dst(r);
//setting value of all pixel in output
//image to the encoded value for visualization
roi.setTo(cv::Scalar::all(code));
112
113
114
115
116
the code for the same can be found in the git repo for OpenVisionLibrary https://github.com/pi19404/OpenVision/ in following
files ImgFeatures/lbpfeatures.hpp and lbpFeatures.cpp files
8|8