How to save feature value from histogram of LBP image in Matlab? -
i'm using local binary pattern (lbp) extract features of group of images (500 images in training folder , 100 images in test folder). indeed, had extracted these features i'm not sure whether saved in correct way or not.
here part of code extract features:
for x = 1:total_images % specify images names full path , extension full_name= fullfile(test_set, filenames(x).name); % read images training folder i2 = imread(full_name); i3=i2; m=size(i2,1); n=size(i2,2); i=2:m-1 j=2:n-1 c=i2(i,j); i3(i-1,j-1)=i2(i-1,j-1)>c; i3(i-1,j)=i2(i-1,j)>c; i3(i-1,j+1)=i2(i-1,j+1)>c; i3(i,j+1)=i2(i,j+1)>c; i3(i+1,j+1)=i2(i+1,j+1)>c; i3(i+1,j)=i2(i+1,j)>c; i3(i+1,j-1)=i2(i+1,j-1)>c; i3(i,j-1)=i2(i,j-1)>c; 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 featurematrix {x} = hist(lbp,0:255); end by using code, lbp features of images i'm not sure saving them correctly in matrix. how save feature value histogram of lbp image? want store value each image.
featurematrix matrix data stored in. should consist of 500 rows, each row should has features of each image.
any answer appreciated.
you should initialize feature matrix before entering outer loop (if know size of lbp):
featurematrix = zeros(total_images,size_lbp); % size_lbp number of columns of lbp.
then replace featurematrix {x} = hist(lbp,0:255); in loop with:
featurematrix(x,:) = hist(lbp,255);
i hope works you!
Comments
Post a Comment