Matlab Bag of Words 图片范畴分类
来源:互联网 发布:优化发展环境调研报告 编辑:程序博客网 时间:2024/05/18 02:00
Matlab Bag of Visual Words 范畴分类
Bag of words的原理 (附opencv代码)http://blog.csdn.net/wsj998689aa/article/details/47089153
Matlab的官方教程:
https://cn.mathworks.com/help/vision/ug/image-classification-with-bag-of-visual-words.html
https://cn.mathworks.com/help/vision/examples/image-category-classification-using-bag-of-features.html
代码:
Matlab提供的代码里需要下载Caltech101数据集,下了半天才下下来。现在上传到百度云。链接:https://pan.baidu.com/s/1dFrMGvv
% % Location of the compressed data set% url = 'http://www.vision.caltech.edu/Image_Datasets/Caltech101/101_ObjectCategories.tar.gz';% % Store the output in a temporary folder% outputFolder = fullfile(tempdir, 'caltech101'); % define output folder% if ~exist(outputFolder, 'dir') % download only once% disp('Downloading 126MB Caltech101 data set...');% untar(url, outputFolder);% end% rootFolder = fullfile(outputFolder, '101_ObjectCategories');rootFolder='D:\TensorflowProjects\6class\101_ObjectCategories';categories = {'airplanes', 'ferry', 'laptop'};imds = imageDatastore(fullfile(rootFolder, categories), 'LabelSource', 'foldernames');tbl = countEachLabel(imds) %计算每一个label的个数minSetCount = min(tbl{:,2}); % determine the smallest amount of images in a category 最小的图片集的个数% Use splitEachLabel method to trim the set. 每一类随机选取minSetCount个图片imds = splitEachLabel(imds, minSetCount, 'randomize');% Notice that each set now has exactly the same number of images.countEachLabel(imds)%分为验证集和训练集[trainingSet, validationSet] = splitEachLabel(imds, 0.3, 'randomize');% Find the first instance of an image for each category%读取一张图片并显示airplanes = find(trainingSet.Labels == 'airplanes', 1);ferry = find(trainingSet.Labels == 'ferry', 1);laptop = find(trainingSet.Labels == 'laptop', 1);% figuresubplot(1,3,1);imshow(readimage(trainingSet,airplanes))subplot(1,3,2);imshow(readimage(trainingSet,ferry))subplot(1,3,3);imshow(readimage(trainingSet,laptop))bag = bagOfFeatures(trainingSet);%获取视觉语义包img = readimage(imds, 1);featureVector = encode(bag, img);% Plot the histogram of visual word occurrencesfigurebar(featureVector)title('Visual word occurrences')xlabel('Visual word index')ylabel('Frequency of occurrence')categoryClassifier = trainImageCategoryClassifier(trainingSet, bag);confMatrix = evaluate(categoryClassifier, trainingSet);confMatrix = evaluate(categoryClassifier, validationSet);% Compute average accuracymean(diag(confMatrix));img = imread(fullfile(rootFolder, 'airplanes', 'image_0690.jpg'));[labelIdx, scores] = predict(categoryClassifier, img);% Display the string labelcategoryClassifier.Labels(labelIdx)
阅读全文
0 0
- Matlab Bag of Words 图片范畴分类
- Bag of Words/Bag of Features的Matlab源码发布
- Bag of words(matlab实现)
- Bag of words模型
- Bag of words模型
- bag of words
- Bag-of-words model
- Bag-of-words模型
- BOW(bag of words)
- Bag-of-words模型
- Bag-of-words model
- Bag of Words
- bag of words
- Bag-of-words model
- Bag of Words模型
- Bag-of-words模型
- Bag of Words
- Bag-of-words model
- 存储过程
- TCP/IP学习笔记(12)——DNS:域名系统
- 二叉树重建(前中序遍历求后序模板刘汝佳小白本)
- C
- Odoo10实战一:模块创建
- Matlab Bag of Words 图片范畴分类
- 词梯游戏
- 《网易编程题》下厨房
- Java关键字之(static与final)2
- JVM知识总结
- 楼天成回忆录
- Java String和StringBuffer两个类。
- 删除一个字符串中的重复字符
- <TensorFlow Machine Learning Cookbook>学习笔记(1.3)