Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Pi19404
January 20, 2014
Contents
Contents
Random Ferns for patch description
0.1 Introduction . . 0.2 Implementation 0.3 Code . . . . . . . . References . . . . . . . . . . . . Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
3 5 6 9
2 | 10
P C
For real time application we require features that can be easily computed and encoded.The concept of Local Binary patterns has become popular for texture analysis and patch description due to it small memory and computational requirement.
In case of Local binary features each patch is described by a bit string. The value of each bit is derived by performing some binary test on the image patch
3 | 10
Since each group contains S features and we are required to maintain a joint PDF we require 2S entries.And since there are M groups total entires required are M 2S .
F
The feature points used in binary tests are selected randomly from a normal distribution. The grouping of features points is also performed randomly. We will approximate the joint PDF using histogram.Each fern consists of S binary features
4 | 10
i = argmax
1
K
= 1K P (fk jC = ci )
(5) (6)
A important feature of this scheme of modelling does not require us to store the training data. Also we can perform incremental learning since we have to update only the counts in the statistical model.
5 | 10
0.3 Code
The code for the same can be found at git repo https://github. com/pi19404/OpenVision/ in I mgF eatures=randomf erns:cpp and I mgF eatures=randomf files Some important functions are also provided below class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
RandomF erns
nclude "randomferms.h" give a feature vector of size M(number of ferms) we compute the output of ensemble classifier as average of individual classifiers oat RandomFerns::calcConfidence(vector<int> features) float conf=0.0; for(int i=0;i<features.size();i++) { //posterioir is a vector consisting of posterior probabilities of PDF //i*numIndices marks the start point of joint PDF of each fern conf=conf+posteriors[i*_numIndices+features[i]]; } return conf/(features.size());
while updating the posterior probabilities after updating the class histograms id RandomFerns::updatePosterior(vector<int> features,bool class1,int ammount)
6 | 10
for(int i=0;i<features.size();i++) { int arrayIndex=(i*_numIndices)+features[i]; class1?positive[arrayIndex]+=ammount:negatives[arrayIndex]+=ammount; //update the posterior posteriors[arrayIndex]=(((float)positive[arrayIndex]))/((float)positive[ } / writeToFile("/home/pi19404/config_oc.txt");
compute the location points for the binary tests for locations of ferns we select the points such that they lie at random locat in a rectangular ROI of size 1,the points are selected such that adjacent points will most likely not lie in the same quadrant random location of points as well as random selection of quadrant are used id RandomFerns::init() points.resize(_numFerns); int toggle=0; for(int i=0;i<_numFerns;i++) { vector<Point2f> px=points[i]; for(int j=0;j<2*_numFeatures;j++) { Point2f p; p.x=((float)std::rand())/(float)RAND_MAX; p.y=((float)std::rand())/(float)RAND_MAX; p.x=p.x/2; p.y=p.y/2; toggle=((float)std::rand())/(float)RAND_MAX; if(toggle<0.25) { p.x=0.5-p.x; p.y=0.5-p.y; } else if(toggle<0.5) { p.x=0.5+p.x;
7 | 10
p.y=0.5+p.y; } else if(toggle < 0.75) { p.x=0.5-p.x; p.y=0.5+p.y; } else if(toggle <1) { p.x=0.5+p.x; p.y=0.5-p.y; } px.push_back(p); toggle=!toggle; } points[i]=px;
function to compute fern feature for a rectangular region in the image ctor<int> RandomFerns::computeFeatures(const Rect r,const Mat image)
vector<int> features; features.resize(0); Mat roi=image(r); for(int i=0;i<points.size();i++) { int index=0; vector<Point2f> pp=points[i]; for(int j=0;j<pp.size();j=j+2) { index <<=1;
8 | 10
Point2f p=pp[j]*r.width; Point2f p1=pp[j+1]*r.height; uchar val1=roi.at<uchar>(p.x,p.y); uchar val2=roi.at<uchar>(p1.x,p1.y); if((int)val1 >(int)val2) { index|=1; } } } return features; features.push_back(index);
9 | 10
Bibliography
Bibliography
[1] Martin Godec et al. On-Line Random Naive Bayes for Tracking. In: ICPR. IEEE, 2010, pp. 35453548.
icpr2010.html#GodecLSB10.
[2]
Zdenek Kalal, Krystian Mikolajczyk, and Jiri Matas. Tracking-Learning-Detection. In: IEEE Transactions on Pattern Analysis and Machine Intelligence 34.7 (2012), pp. 14091422.
org/10.1109/TPAMI.2011.239.
[3]
issn:
0162-8828.
doi: http://doi.ieeecomputersociety.
Mustafa zuysal, Pascal Fua, and Vincent Lepetit. Fast keypoint recognition in ten lines of code. In: In Proc. IEEE Conference on Computing Vision and Pattern
Recognition.
2007.
10 | 10