我从三类载有 100 图像的车辆中提取了特征。我的数据集中有三个单独的文件夹,包括自行车,汽车和摩托车。它们位于目录'dataset \ trainSet'中。我已经在另一个目录'dataset \ testSet'中 60 个图像来测试和识别车辆。我已经搜索了 mathworks.com 文档,但不了解如何在Matlab示例代码中使用神经网络。
现在,我需要
1.用lbp提取的特征训练神经网络
2.测试我上面提到的目录中的每个图像
3.将输入图像分类为三类车辆并识别
下面是我的示例代码==>
%%Clearing
clear all;
close all;
clc
%input = imread('dataset\testSet\14.JPG');
%%Importing Training Dataset
imSet = imageSet('dataset\trainSet','recursive');
[imSet.Count]
%%Prepare Training Sets
minSetCount = min([imSet.Count]);
trainingSet = partition(imSet, minSetCount, 'randomize');
[trainingSet.Count]
%%Copy to individual category
bicycleData = trainingSet(1);
carData = trainingSet(2);
motorbikeData = trainingSet(3);
% Create a cell array to store features per image.
bicycleFeatures = cell(size(bicycleData.ImageLocation));
image = imread(bicycleData.ImageLocation{1});
bicycleFeatures{1} = extractLBPFeatures(rgb2gray(image));
netBicycleFeatures = bicycleFeatures{1};
carFeatures = cell(size(carData.ImageLocation));
image = imread(carData.ImageLocation{1});
carFeatures{1} = extractLBPFeatures(rgb2gray(image));
netCarFeatures = carFeatures{1};
motorbikeFeatures = cell(size(motorbikeData.ImageLocation));
image = imread(motorbikeData.ImageLocation{1});
motorbikeFeatures{1} = extractLBPFeatures(rgb2gray(image));
netMotorbikeFeatures = motorbikeFeatures{1};
for i = 2:length(bicycleFeatures)
% Read in individual image, and convert to grayscale to extract features.
image = imread(bicycleData.ImageLocation{i});
bicycleFeatures{i} = extractLBPFeatures(rgb2gray(image));
image = imread(carData.ImageLocation{i});
carFeatures{i} = extractLBPFeatures(rgb2gray(image));
image = imread(motorbikeData.ImageLocation{i});
motorbikeFeatures{i} = extractLBPFeatures(rgb2gray(image));
netBicycleFeatures = netBicycleFeatures + bicycleFeatures{i};
netCarFeatures = netCarFeatures + carFeatures{i};
netMotorbikeFeatures = netMotorbikeFeatures + motorbikeFeatures{i};
end
%inputFeature = extractLBPFeatures(rgb2gray(input));
netBicycleFeatures = netBicycleFeatures / length(bicycleFeatures);
netCarFeatures = netCarFeatures / length(carFeatures);
netMotorbikeFeatures = netMotorbikeFeatures / length(motorbikeFeatures);
%%Display Histogram
bar([netBicycleFeatures; netCarFeatures; netMotorbikeFeatures]','grouped')
title('LBP Features Of Bicycle, Car and Motorbike');
xlabel('LBP Histogram Binaries');
legend('Bicycle TrainingSet','Car TrainingSet','Motorbike TrainingSet');
%Train & Test a neural network and classify the input
请帮助我实现我的示例代码。