如何实现统一LBP?
可能的重复:
MATLAB 中的本地二进制模式
我想实现统一的 LBP。这是维基百科给出的统一 LBP 的定义。
如果二进制模式是一致的,则局部二进制模式被称为统一的 最多包含两个从 0 到 1 的按位转换,反之亦然 当位模式循环遍历时。例如, 模式 00000000(0 个转换)、01110000(2 个转换)和 11001111(2 个过渡)是均匀的,而图案 11001001(4 转换)和 01010010(6 个转换)不是。在计算中 在 LBP 标签中,使用统一的模式,以便有 每个统一图案和所有非统一图案都有单独的标签 图案用单个标签标记。例如,当使用 (8,R)邻域,共有256种模式,其中58种是 统一,产生 59 种不同的标签。
我已经为 LBP 编写了代码,但不确定如何将其转换为统一的 LBP。下面是 LBP 的代码。
for i=2:m-1
for j=2:n-1
J0=I2(i,j);
I3(i-1,j-1)=I2(i-1,j-1)>J0;
I3(i-1,j)=I2(i-1,j)>J0;
I3(i-1,j+1)=I2(i-1,j+1)>J0;
I3(i,j+1)=I2(i,j+1)>J0;
I3(i+1,j+1)=I2(i+1,j+1)>J0;
I3(i+1,j)=I2(i+1,j)>J0;
I3(i+1,j-1)=I2(i+1,j-1)>J0;
I3(i,j-1)=I2(i,j-1)>J0;
LBP(i,j)=I3(i-1,j-1)*2^7+I3(i-1,j)*2^6+I3(i-1,j+1)*2^5+I3(i,j+1)*2^4+I3(i+1,j+1)*2^3+I3(i+1,j)*2^2+I3(i+1,j-1)*2^1+I3(i,j-1)*2^0;
end
end
figure,imshow(uint8(LBP))
任何帮助将不胜感激。我正在使用 MATLAB。
Possible Duplicate:
Local Binary Pattern in MATLAB
I would like to implement uniform LBP. This is the definiton given by wikipedia for uniform LBP.
A local binary pattern is called uniform if the binary pattern
contains at most two bitwise transitions from 0 to 1 or vice versa
when the bit pattern is traversed circularly. For example, the
patterns 00000000 (0 transitions), 01110000 (2 transitions) and
11001111 (2 transitions) are uniform whereas the patterns 11001001 (4
transitions) and 01010010 (6 transitions) are not. In the computation
of the LBP labels, uniform patterns are used so that there is a
separate label for each uniform pattern and all the non-uniform
patterns are labeled with a single label. For example, when using
(8,R) neighborhood, there are a total of 256 patterns, 58 of which are
uniform, which yields in 59 different labels.
I have written code for LBP but not sure how to convert it to a uniform LBP. Below is the code for LBP.
for i=2:m-1
for j=2:n-1
J0=I2(i,j);
I3(i-1,j-1)=I2(i-1,j-1)>J0;
I3(i-1,j)=I2(i-1,j)>J0;
I3(i-1,j+1)=I2(i-1,j+1)>J0;
I3(i,j+1)=I2(i,j+1)>J0;
I3(i+1,j+1)=I2(i+1,j+1)>J0;
I3(i+1,j)=I2(i+1,j)>J0;
I3(i+1,j-1)=I2(i+1,j-1)>J0;
I3(i,j-1)=I2(i,j-1)>J0;
LBP(i,j)=I3(i-1,j-1)*2^7+I3(i-1,j)*2^6+I3(i-1,j+1)*2^5+I3(i,j+1)*2^4+I3(i+1,j+1)*2^3+I3(i+1,j)*2^2+I3(i+1,j-1)*2^1+I3(i,j-1)*2^0;
end
end
figure,imshow(uint8(LBP))
Any help would be appreciated. I am using MATLAB.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
步骤
LBP
中的值构建一个查找表。LBP
映射到 59 个标签。labeled = table(LBP) % 这称为表查找或 MATLAB 索引。
建议(虽然对于实现来说不是必需的)
I3(1), I3(2), ... I3(8)
因为每次您移动到下一个中心像素( i,j)
。Steps
LBP
.LBP
into the 59 labels using the table.labeled = table(LBP) % this is called table lookup or MATLAB indexing.
Suggestions (although not necessary for implementation)
I3(1), I3(2), ... I3(8)
because they will be reassigned each time you move on to the next center pixel(i,j)
.我尝试了这段代码:
I tried this code: