在openCV中使用RGB图像的弓/视觉代码本/功能包?

在openCV中使用RGB图像的弓/视觉代码本/功能包?,opencv,svm,Opencv,Svm,我能够使用灰度图像创建一个BOW/visualcodebook。我稍后将使用此弓进行SVM分类。但是我想保留颜色信息。因此,我想创建3D弓,即所有通道。但我怎么能这样做呢 //Obtain the set of bags of features. char * filename = new char[100]; Mat input; vector<KeyPoint> keypoints; Mat descriptor; Mat featuresUnclu

我能够使用灰度图像创建一个BOW/visualcodebook。我稍后将使用此弓进行SVM分类。但是我想保留颜色信息。因此,我想创建3D弓,即所有通道。但我怎么能这样做呢

//Obtain the set of bags of features.

char * filename = new char[100];        
Mat input;    

vector<KeyPoint> keypoints;
Mat descriptor;

Mat featuresUnclustered;
//The SIFT feature extractor and descriptor
SiftDescriptorExtractor detector;    

//feature descriptors and build the vocabulary
for(int f=0;f<999;f+=50){        
    sprintf(filename,"G:\\testimages\\image\\%i.jpg",f);

    input = imread(filename, CV_LOAD_IMAGE_GRAYSCALE); //Load as grayscale                
    //detect feature points
    detector.detect(input, keypoints);
    //compute the descriptors for each keypoint
    detector.compute(input, keypoints,descriptor);        
    //put the all feature descriptors in a single Mat object 
    featuresUnclustered.push_back(descriptor);        
    //print the percentage
    printf("%i percent done\n",f/10);
}        

//Construct BOWKMeansTrainer
//the number of bags
int dictionarySize=200;
//define Term Criteria
TermCriteria tc(CV_TERMCRIT_ITER,100,0.001);
//retries number
int retries=1;
//necessary flags
int flags=KMEANS_PP_CENTERS;
//Create the BoW (or BoF) trainer
BOWKMeansTrainer bowTrainer(dictionarySize,tc,retries,flags);
//cluster the feature vectors
Mat dictionary=bowTrainer.cluster(featuresUnclustered);    
//store the vocabulary
FileStorage fs("dictionary.yml", FileStorage::WRITE);
fs << "vocabulary" << dictionary;
fs.release();
//获取特征包集。
char*filename=新字符[100];
Mat输入;
矢量关键点;
Mat描述符;
席状特征;
//SIFT特征提取器和描述符
SiftDescriptorExtractor检测器;
//特征描述符并构建词汇表

对于(int f=0;fI)来说,我认为您应该分别计算3个通道中每个通道的功能,并将它们聚集成一个弓形。我不认为有3个弓形有什么意义。@user1965914:事实上,我知道我可以使用“opponentColordDescriptorExtractor”但我无法使用…你知道吗…?它将RGB空间转换为对手颜色空间,然后分别计算每个空间的描述符。最终的描述符向量只是3个空间中每个空间的串联。根据你的描述,我建议为什么不使用RGB颜色直方图作为颜色描述符。也许你可以将局部特征和颜色合并为弓形。在进行聚类之前,只需将颜色向量归一化即可