I'd like to implement the character recognition. The implementation of LBP pattern and spatial histogram is fine for me, but I face some problems when doing the PCA process.
I've looked for the internet resources, but cannot solve my difficulty. As for my code, the size of spatial_histogram is 116384 (rowcol) . But after the projection, the size of projection_result is only 1*1. My purpose is to reduce the dimension of the obtained spatial histogram into smaller size, so that I can then port the result with smaller size into SVM for training. How can I make it turn the size of feature vector of my spatial histogram into 200?
Besides, I have seen a lot about PCA's function like "project", "backproject", but I'm quite confused about that.
Here's my piece of code:
Mat inImg = imread(filename,0);
Mat lbp_image(inImg.rows-2, inImg.rows-2, CV_8UC1, Scalar(0));
int radius = 1;
int neighbors = 8;
int grid_x = 8, grid_y = 8;
olbp(inImg, lbp_image);
Mat histMat = spatial_histogram(
lbp_image,
static_cast<int>(std::pow(2.0, static_cast<double>(neighbors))),
grid_x,
grid_y,
true);
histograms.push_back(histMat);
PCA pca(histMat,Mat(),CV_PCA_DATA_AS_ROW, 200); // histMat <- 1*16384
pca.project(histMat,projection_result);