LBP图像特征提取代码
时间: 2023-12-20 07:28:45 浏览: 123
LBP(Local Binary Pattern)是一种用于图像纹理分析的特征描述子。下面是三个不同来源的LBP图像特征提取代码:
1. 可以参考博客LBP特征_羊肉串串魅力无穷的博客-CSDN博客_lbp特征,里面描述的很详细,可以供我们参考学习。
2. MATLAB实现LBP特征提取的代码如下:
```
function [LBP] = LBP_feature_extraction(image)
% image: 输入的灰度图像
% LBP: 输出的LBP特征
[m,n] = size(image);
LBP = zeros(m-2,n-2);
for i = 2:m-1
for j = 2:n-1
center = image(i,j);
code = 0;
code = code + (image(i-1,j-1)>=center)*2^7;
code = code + (image(i-1,j)>=center)*2^6;
code = code + (image(i-1,j+1)>=center)*2^5;
code = code + (image(i,j+1)>=center)*2^4;
code = code + (image(i+1,+1)>=center)*2^3;
code = code + (image(i+1,j)>=center)*2^2;
code = code + (image(i+1,j-1)>=center)*2^1;
code = code + (image(i,j-1)>=center)*2^0;
LBP(i-1,j-1) = code;
end
end
```
3. 利用skimage库中的local_binary_pattern函数实现LBP的特征提取,代码如下:
```
from skimage.feature import local_binary_pattern
radius = 1
n_points = 8 * radius
METHOD = 'uniform'
lbp = local_binary_pattern(image, n_points, radius, METHOD)
```
阅读全文