首先,我想说我真的是CV的新手,也许有些明显的事情我没想到,所以请毫不犹豫地提及该类别。
我正在尝试实现场景分类,为了简便起见,目前在室内和室外图像之间进行分类。
我要实现这一点的想法是使用要点描述符,该描述符创建具有场景某些参数的向量。
为了获得可靠的分类,我使用了室内和室外图像,每个图像有100个样本,使用了摘要描述符,在其中创建了训练矩阵,并在其上使用了“ svmtrain”。这是一个非常简单的代码,显示了我如何训练要点向量:
train_label= zeros(size(200,1),1);
train_label(1:100,1) = 0; % 0 = indoor
train_label(101:200,1) = 1; % 1 = outdoor
training_mat(1:100,:) = gist_indoor1;
training_mat(101:200,:) = gist_outdoor1;
test_mat = gist_test;
SVMStruct = svmtrain(training_mat ,train_label, 'kernel_function', 'rbf', 'rbf_sigma', 0.6);
Group = svmclassify(SVMStruct, test_mat);
问题是结果非常糟糕。
我读到优化“ rbf” kernell的约束和gamma参数应该可以改善分类,但是:
我不确定如何使用多维数据向量进行优化(Mathworks网站中给出的优化示例是二维的,而我的是512),有什么建议怎么开始的?
我可能完全错了方向,请指出是否正确。
编辑:谢谢Darkmoor!我将尝试使用此工具箱进行校准,并可能尝试改善特征提取。希望当我有一个有效的分类时,我将在这里发布。
编辑2:通过从SUN数据库获取室内和城市室外图像的要点描述符,忘记了更新,并通过使用libsvm工具箱使用优化的参数进行训练,当在来自以下位置的图片上测试模型时,我设法达到了95%的分类率我的公寓和外面的街道。
我对数据库中的城市室外场景和自然场景进行了相同的处理,并且在对我的国家/地区的各种场景进行测试时达到了相似的准确性。
我用来创建数据矩阵的代码是从此处获取的,并做了非常小的修改:
% GIST Parameters:
clear param
param.imageSize = [256 256]; % set a normalized image size
param.orientationsPerScale = [8 8 8 8]; % number of orientations per scale (from HF to LF)
param.numberBlocks = 4;
param.fc_prefilt = 4;
%Obtain images from folders
sdirectory = 'C:\Documents and Settings\yotam\My Documents\Scene_Recognition\test_set\indoor&outdoor_test';
jpegfiles = dir([sdirectory '/*.jpg']);
% Pre-allocate gist:
Nfeatures = sum(param.orientationsPerScale)*param.numberBlocks^2;
gist = zeros([length(jpegfiles) Nfeatures]);
% Load first image and compute gist:
filename = [sdirectory '/' jpegfiles(1).name];
img = imresize(imread(filename),param.imageSize);
[gist(1, :), param] = LMgist(img, '', param); % first call
% Loop:
for i = 2:length(jpegfiles)
filename = [sdirectory '/' jpegfiles(i).name];
img = imresize(imread(filename),param.imageSize);
gist(i, :) = LMgist(img, '', param); % the next calls will be faster
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句