uniform Pattern LBP特征matlab实现

原理不讲了,matlab实现 ,网上没找到好用的,这个最后做了归一化。

%function table_3 = ulbp(I)
clear
clc
img=imread('b.jpg');
I = rgb2gray(img);
picture=I;
x=size(picture,1);
y=size(picture,2);
lbp_n=uint8(zeros(x,y));
table=[];
tab=[];
temp=1;
for i=1:256
    if(getHoptimes(i)<3)
        table(i)=temp;
        temp=temp+1;
    end
end
k1=1;
for i=2:1:x-1
    for j=2:1:y-1
        neighbor=uint8(zeros(1,8));    
        neighbor(1,1)=picture(i-1,j-1);
        neighbor(1,4)=picture(i-1,j);
        neighbor(1,6)=picture(i-1,j+1);
        neighbor(1,7)=picture(i,j+1);
        neighbor(1,8)=picture(i+1,j+1);
        neighbor(1,5)=picture(i+1,j);
        neighbor(1,3)=picture(i+1,j-1);
        neighbor(1,2)=picture(i,j-1);
        center=picture(i,j);
        temp1=uint8(0);
        for k=1:1:8
             temp1 =temp1+ (neighbor(1,k) >= center)* 2^(k-1);
        end
        if(temp1==255)
            lbp_n(i-1,j-1)=table(256);
        else
            lbp_n(i-1,j-1)=table(temp1+1);   
        end
    end
end
table_1(59)=[0];
table_3(59)=[0];
h=1;
for i=1:x
    for j=1:y
        if lbp_n(i,j)==0
            table_1(59)=table_1(59)+1;
        else
             table_1(lbp_n(i,j))=table_1(lbp_n(i,j))+1;
        end 
    end
end
table_3=table_1/sum(table_1);
%end
sum=1;
for i=1:x
    for j=1:y
        if lbp_n(i,j)==58
            sum=sum+1;
        end
    end
end


        

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值