summaryrefslogtreecommitdiff
path: root/macros/bagOfFeatures.sci
diff options
context:
space:
mode:
authorshamikam2017-01-16 02:56:17 +0530
committershamikam2017-01-16 02:56:17 +0530
commita6df67e8bcd5159cde27556f4f6a315f8dc2215f (patch)
treee806e966b06a53388fb300d89534354b222c2cad /macros/bagOfFeatures.sci
downloadFOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.tar.gz
FOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.tar.bz2
FOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.zip
First CommitHEADmaster
Diffstat (limited to 'macros/bagOfFeatures.sci')
-rw-r--r--macros/bagOfFeatures.sci50
1 files changed, 50 insertions, 0 deletions
diff --git a/macros/bagOfFeatures.sci b/macros/bagOfFeatures.sci
new file mode 100644
index 0000000..480d775
--- /dev/null
+++ b/macros/bagOfFeatures.sci
@@ -0,0 +1,50 @@
+function [bag]=bagOfFeatures(imageSet,varargin)
+// This function is used to create a Bag-of-Words model (BoW model).
+//
+// Calling Sequence
+// bag = bagOfFeatures(imgSet);
+// bag = bagOfFeatures(imgSet, Name, Value, ...);
+//
+// Parameters
+// bag: Bag of visual words
+// imgSet: An imageSet structure
+// VocabularySize: (Optional) Number of visual words (Default- 500)
+// StrongestFeatures: (Optional) Fraction of strongest features (Default- 1.0)
+// Upright: (Optional) Orientation of SURF feature vector (Default- true)
+// Verbose: (Optional) Enable progress display to screen (Default- true)
+//
+// Description
+// BoW model is applied to classify images by treating image features as words. The bagOfFeatures object contains a bag of visual words that help in image classification.
+//
+// Examples
+// imgSet = imageSet(directory,'recursive');
+// [trainingSet testSet] = partition(imgSet,[0.8]);
+// bag = bagOfFeatures(trainingSet);
+//
+// Authors
+// Rohit Suri
+// Umang Agrawal
+
+ [lhs rhs]=argn(0);
+ if lhs>1
+ error(msprintf(" Too many output arguments"));
+ elseif rhs<1
+ error(msprintf("At least one argument is required"));
+ elseif rhs>9
+ error(msprintf(" Too many input arguments"));
+ end
+ imageSetList=imageSetToList(imageSet);
+ select rhs
+ case 1 then
+ bagList=opencv_bagOfFeatures(imageSetList);
+ case 3 then
+ bagList=opencv_bagOfFeatures(imageSetList,varargin(1),varargin(2));
+ case 5 then
+ bagList=opencv_bagOfFeatures(imageSetList,varargin(1),varargin(2),varargin(3),varargin(4));
+ case 7 then
+ bagList=opencv_bagOfFeatures(imageSetList,varargin(1),varargin(2),varargin(3),varargin(4),varargin(5),varargin(6));
+ case 9 then
+ bagList=opencv_bagOfFeatures(imageSetList,varargin(1),varargin(2),varargin(3),varargin(4),varargin(5),varargin(6),varargin(7),varargin(8));
+ end
+ bag=struct('FilePath',bagList(2)(1,1),'VocabularySize',bagList(3)(1,1),'StrongestFeatures',bagList(4)(1,1),'Upright',bagList(5)(1,1));
+endfunction