簡體   English   中英

如何從Matlab數據集中提取LBP特征?

[英]How to extract LBP features from datasets in Matlab?

我已經了解了如何如以下示例中所述從單個圖像中提取特征: https : //www.mathworks.com/help/vision/ref/extractlbpfeatures.html

現在,我正在為我的matlab項目處理1000個圖像的數據集,以提取自行車,汽車和摩托車的特征。 我的數據集中有三個單獨的文件夾,包括自行車,汽車和摩托車。 在執行過程中,我收到錯誤消息,

Error using extractLBPFeatures>parseInputs (line 148)

Expected I to be one of these types:

double, single, int16, uint16, uint8, logical

Instead its type was imageSet.

Error in extractLBPFeatures (line 129)

params = parseInputs(I,varargin{:});

Error in LBP (line 21)

bycycleLBP = extractLBPFeatures(bycycleData,'Upright',false);

我該怎么辦? 以下是我的示例代碼==>

imSet = imageSet('dataset\train','recursive');

bicycleData = imSet(1);
carData = imSet(2);
motorbikeData = imSet(3);

%%Extract LBP Features
bicycleLBP = extractLBPFeatures(bicycleData,'Upright',false);
carLBP = extractLBPFeatures(carData,'Upright',false);
motorbikeLBP = extractLBPFeatures(motorbikeData,'Upright',false);

bicycle = bicycleLBP.^2;
car = carLBP.^2;
motorbike = motorbikeLBP.^2;

figure
bar([bicycle; car; motorbike]','grouped');
title('LBP Features Of bicycle, car and motorbike');
xlabel('LBP Histogram Bins');
legend('Bicycle','Car','Motorbike');

請幫助我實現示例代碼。

在嘗試提取特征之前,讓我們看兩個變量。

>> whos imSet bicycleData
  Name             Size            Bytes  Class       Attributes            
  imSet            1x3              1494  imageSet 
  bicycleData      1x1               498  imageSet 

變量imSet是3個imageSet對象的列表。 第一個代表自行車,因此您可以將自行車imageSet適當地拉入其自己的變量bicycleData ,它是一個奇異的imageSet 到目前為止一切順利,但是當我們看一下extractLBPFeatures的文檔時...

features = extractLBPFeatures(I,Name,Value)

I —輸入圖像

輸入圖像,指定為真實且非稀疏的M×N 2-D灰度圖像。


此功能一次只能提取一張灰度圖像的特征。 您必須遍歷imageSet提取一個特征。

% Create a cell array to store features per image.
bicycleFeatures = cell(size(bicycleData.ImageLocation));

for i = 1:length(bicycleFeatures)
    % Read in individual image, and convert to grayscale to extract features.
    image = imread(bicycleData.ImageLocation{i});
    bicycleFeatures{i} = extractLBPFeatures(rgb2gray(image));
end

請記住,您仍然需要進行后處理工作。 這將提取每個圖像的特征,因此您必須確定如何在每個數據集中組合特征數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM