function His=lbp(image,r)
[ysize xsize] = size(image);
y=ysize-r;
x=xsize-r;
C = double(image);
LBP=zeros(ysize-2*r,xsize-2*r);
n=zeros(1,8);
for i=r+1:y
for j=r+1:x
nc=C(i,j);
n(1)=C(i,j+r);
n(2)=C(i+r,j+r);
n(3)=C(i+r,j);
n(4)=C(i+r,j-r);
n(5)=C(i,j-r);
n(6)=C(i-r,j-r);
n(7)=C(i-r,j);
n(8)=C(i-r,j+r);
for k=1:8
if n(k)>nc
s=1;
else
s=0;
end
LBP(i-r,j-r)=LBP(i-r,j-r)+s*2^(k-1);
end
end
end
2022-05-05 20:28:50
565B
纹理算法
1