matlab - LBP not working for texture matching -
after seeing few papers had used lbp texture recognition, implemented simple lpb , used bhattacharya distance score similarity. the score not enough, different textures. doing error in code ?or lbp not measure texture.
function lbp() clc; im=imread('bark1.jpg'); subplot(2,2,1);imshow(im); [r c]=size(im); h1=tex_lpb(im,r,c); subplot(2,2,2);plot(h1 ); im_2=imread('t_shirt.jpg'); im_2=rgb2gray(im_2); subplot(2,2,3);imshow(im_2); [r c]=size(im_2); h2=tex_lpb(im_2,r ,c ); subplot(2,2,4);plot(h2); weight=sum(sqrt(h1.*h2)) end function h= tex_lpb(im,r,c) im_lpb=zeros(r,c); i=2:r-1 j=2:c-1 a=[]; %checking 8 nieghbours %n-w if(im(i,j)>im(i-1,j-1)) a=[a 0]; else a=[a 1]; end %n if(im(i,j)>im(i-1,j)) a=[a 0]; else a=[a 1]; end %n-e if(im(i,j)>im(i-1,j+1)) a=[a 0]; else a=[a 1]; end %e if(im(i,j)>im(i,j+1)) a=[a 0]; else a=[a 1]; end %s-e if(im(i,j)>im(i+1,j+1)) a=[a 0]; else a=[a 1]; end %s if(im(i,j)>im(i+1,j)) a=[a 0]; else a=[a 1]; end %s-w if(im(i,j)>im(i+1,j-1)) a=[a 0]; else a=[a 1]; end %w if(im(i,j)>im(i,j-1)) a=[a 0]; else a=[a 1]; end b=0; dec=8; %changing decimal k=0:7 b=a(dec)*(2^k)+b; dec=dec-1; end b; im_lpb(i,j)=b; end end h=hist_vec(im_lpb);% getting histogram end function h=hist_vec(im_lpb) [r c]=size(im_lpb); h=zeros(1,256); i=1:r j=1:c h(1,im_lpb(i,j)+1)=h(1,im_lpb(i,j)+1)+1; end end h=h/sum(h); end
image dataset
matlab image-processing textures histogram
No comments:
Post a Comment