本文介绍了如何在Matlab中从LBP图像的直方图中保存特征值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用本地二进制模式(LBP)提取图像组的功能(训练"文件夹中的500张图像和测试"文件夹中的100张图像) .确实,我已经成功提取了这些功能,但是不确定它们是否以正确的方式保存.

I'm using Local Binary Pattern (LBP) to extract the features of group of images (500 images in Training folder and 100 Images in Test folder). Indeed, I had extracted these features successfully but I'm not sure whether they saved in correct way or not.

这是提取功能的代码的一部分:

Here is a part of code that extract the features:

for x = 1:total_images
% Specify images names with full path and extension    
full_name= fullfile(test_set, filenames(x).name);

% Read images from Training folder
I2 = imread(full_name);
I3=I2;
m=size(I2,1);
n=size(I2,2);

for i=2:m-1
    for 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 

通过使用此代码,我获得了所有图像的LBP功能,但不确定是否将它们正确保存在矩阵中.如何从此LBP图像直方图中保存特征值?我想为每个图像存储此值.

By using this code, I get LBP features of all images but I'm not sure about saving them correctly in a matrix. How to save feature value from this histogram of LBP image? I want to store this value for each image.

featureMatrix是数据将存储在其中的矩阵.它应由500行组成,每行应具有每个图像的所有特征.

featureMatrix is a matrix that data will stored in. It should be consist of 500 rows, each row should has all features of each image.

任何答案将不胜感激.

推荐答案

您应该在进入外循环之前初始化特征矩阵(如果您知道LBP的大小):

you should initialize the feature matrix before entering the outer loop (if you could know the size of LBP):

featureMatrix = zeros(total_images,size_LBP); % where size_LBP is the number of columns of LBP.

然后将循环中的featureMatrix {x} = hist(LBP,0:255);替换为:

then replace featureMatrix {x} = hist(LBP,0:255); in the loop with:

featureMatrix(x,:) = hist(LBP,255);

我希望这对您有用!

这篇关于如何在Matlab中从LBP图像的直方图中保存特征值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 04:12