【发布时间】:2016-05-07 02:44:35
【问题描述】:
我在 MATLAB 中使用特征包对组织学图像进行分类。
这是我使用的代码。它取自`imageCategoryClassificationExample
压缩数据集的位置
url=http://www.vision.caltech.edu/Image_Datasets/Caltech101/101_ObjectCategories.tar.gz';
将输出存储在临时文件夹中
outputFolder = fullfile(tempdir, 'caltech101');
rootFolder = fullfile(outputFolder, '101_ObjectCategories');
imgSets = [ imageSet(fullfile(rootFolder, 'airplanes')), ...
imageSet(fullfile(rootFolder, 'ferry')), ...
imageSet(fullfile(rootFolder, 'laptop')) ];
确定一个类别中的最小图像数量
minSetCount = min([imgSets.Count]);
使用partition 方法修剪集合。
imgSets = partition(imgSets, minSetCount, 'randomize');
将集合分成训练和验证数据。
[trainingSets, validationSets] = partition(imgSets, 0.3, 'randomize');
创建特征分类器包
bag = bagOfFeatures(trainingSets);
此外,bagOfFeatures 对象提供了一个encode 方法
计算图像中视觉单词的出现次数。它产生了一个直方图
这将成为图像的一种新的简化表示。
img = read(imgSets(1), 1);
[featureVector,words] = encode(bag, img);
绘制视觉单词出现的直方图
figure
bar(featureVector)
title('Visual word occurrences')
xlabel('Visual word index')
ylabel('Frequency of occurrence')
在创建特征包对象后,我如何可视化最终的码本以及每个图像由哪些视觉词组成?我可以从这些单词中重建图像吗?我认为这与使用encode 创建visualWords 对象有关。但是之后我该怎么做呢?
【问题讨论】:
标签: matlab computer-vision matlab-cvst object-recognition