Cluster texture based on features extracted from Gabor

I am trying to group textures based on functions extracted from the Gabor bank that I created, but the result is far from what is usually expected, so here is what I do →

1-generate a filter bank (according to Miki's answer here . I get both real and imaginary parts, so that later I can extract the Magnitude function)

void Gabor::generateFilterbank(int bankRows,int bankCols) { bankCol=bankCols; bankRow=bankRows; setBankSize(); int thetaStep=pos_th_max/bankCols; int lambadaStep=(pos_lm_max/bankRows) /10; for (int i=1;i<=bankRows;i++ )//cols=theta rows=lambada for (int j=1;j<=bankCols;j++ ) { int ks=(kernel_size-1)/2; Size KernalSize(ks,ks); double Sigma = pos_sigma; double Lambda = 0.5+(i*lambadaStep); double Theta = (j*thetaStep)*CV_PI/180; double psi = pos_psi;//*CV_PI/180 double Gamma = 0; vector<Mat> realImag; realImag.push_back(getGaborKernel(KernalSize,Sigma,Theta,Lambda,Gamma,psi,CV_32F));//real realImag.push_back(getGaborKernelImag(KernalSize,Sigma,Theta,Lambda,Gamma,psi,CV_32F));//imag Kernels.push_back(realImag); } } 

2-technology input image

 void Gabor::process(Mat img) { img.convertTo(img, CV_32F, 1.0/255, 0); for (int i=0;(unsigned)i<Kernels.size();i++) { vector<Mat > responseIR; for (int j=0;(unsigned)j<Kernels[i].size();j++) { Mat IR ; filter2D(img, IR , CV_32F,Kernels[i][j]); responseIR.push_back(IR ); IR.release(); } responses.push_back(responseIR); } } 

3 - extract function vector from all Gabor answers

  vector<float> Gabor::getGaborFetures(ofstream &out,float name) { vector<float>fetures; Mat magnituder (responses.size(),responses[0][0].rows*responses[0][0].cols,CV_32FC1, Scalar(0.0)); fetures.push_back(name); if (responses.size()>0) { for (int i=0;(unsigned)i<responses.size();i+=2) { vector<float> mag,rel,imag; mat2Vector(responses[i][0],rel); mat2Vector( responses[i][1],imag); cv::magnitude(rel,imag, mag); for (int j=0;j<mag.size();j++) { magnituder.at<float>(i,j) =mag[j]; } } PCA pca( magnituder,Mat(),CV_PCA_DATA_AS_ROW,10); Mat result(pca.project( magnituder)); magnituder.release(); for (int i=0;i<result.rows;i++) { for(int j=0;j<result.cols;j++) { fetures.push_back(result.at<float>(i,j)); } } result.release(); for (int i=0;(unsigned)i<fetures.size();i++) out <<fetures[i]<<","; out<<endl; return fetures; } else { cerr<<"You have to process your image first!"<<endl; return fetures; } } 

4- finally retrieved objects using K-means

 int kt=14; Mat labTexture; kmeans(ftTexture,kt,labTexture,TermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 10000,0.0001),10,KMEANS_RANDOM_CENTERS ); 

I am currently testing the code for this dataset. I expected the cluster data to be installed in 14 classes, for example, all the brick images go to the same folder.

+7
opencv pca k-means textures gabor-filter
source share

No one has answered this question yet.

See similar questions:

6
Opencv getGaborKernel parameters for filter bank
5
In open CV Why is the default phase phase Gabor 90 degrees?
one
Large differences in image are filtered using Gabor's rotating cores.
0
error 2059 with getgaborkernel () in openCV2.3.1 on visual studio C ++ 2010 express
0
How to get the real and imaginary parts of the gabor core matrix in OpenCV

or similar:

6
Opencv getGaborKernel parameters for filter bank
4
Image Texture function using the Gabor filter
one
Square clustering error for texture segmentation
one
creating a gabor texture in c #
one
How to use Gabor filters to extract from an image?
one
Extracting Gabor and SVM Features
one
Large differences in image are filtered using Gabor's rotating cores.
0
Wordnet semantic clustering in python
0
Highlighting Gabor Filters
0
SVM predicts on OpenCV: how can I extract the same number of functions

All Articles