连接SURF功能和Radon功能以训练SVM

时间:2016-03-03 06:59:50

标签: matlab image-processing matlab-cvst surf

是否可以连接2个bagoffeatures对象来训练分类器?

我已经使用SURF点训练了一个分类器:

extractorFcn = @SURFBOW;
bag = bagOfFeatures(trainingSets,'CustomExtractor',extractorFcn);

SURFBOW包含:

[height,width,numChannels] = size(I);
if numChannels > 1
    grayImage = rgb2gray(I);
else
    grayImage = I;
end
multiscaleSURFPoints = detectSURFFeatures(grayImage,'MetricThreshold',100);
features = extractFeatures(grayImage, multiscaleSURFPoints,'Upright',true);
featureMetrics = multiscaleSURFPoints.Metric;

并遵循Matlab的示例:http://www.mathworks.com/help/vision/examples/image-category-classification-using-bag-of-features.html?refresh=true

接下来,我做了类似的事情来提取图像的Radon功能,而不是使用另一个提取器功能,但使用RadonBOW(I),如下所示:

[height,width,numChannels] = size(I);
if numChannels > 1
    grayImage = double(rgb2gray(I));
else
    grayImage = double(I);
end



dx = imfilter(grayImage,fspecial('sobel') ); % x, 3x3 kernel
dy = imfilter(grayImage,fspecial('sobel')'); % y
gradmag = sqrt( dx.^2 + dy.^2 );

% mask by disk
R = min( size(grayImage)/2 ); % radius
disk = insertShape(zeros(size(grayImage)),'FilledCircle', [size(grayImage)/2,R] );
mask = double(rgb2gray(disk)~=0);
gradmag = mask.*gradmag;

% radon transform
theta = linspace(0,180,179);
vars = zeros(size(theta));
for u = 1:length(theta)
    [rad,xp] =radon( gradmag, theta(u) );
    indices = find( abs(xp)<R );
    % ignore radii outside the maximum disk area
    % so you don't sum up zeroes into variance
    vars(u) = var( rad( indices ) );
end
features = vars/norm(vars);
featureMetrics = var(features);

每个人都得到了公平的结果。无论如何要结合这些来使用氡和SURF点来训练分类器?

(我也尝试过使用kmeans手动执行Radon BOW方法,但是,我的结果非常差,所以我认为这是不正确的)

谢谢!

1 个答案:

答案 0 :(得分:2)

当您使用bagOfFeatures时,您调用encode方法,该方法会返回一个包含特征的直方图。您可以将直方图与您的Radon功能连接在同一图像上,并对其进行训练。