Object Detection using Template

- Main Page
- Packages
- Classes
- Files

- File List

All Classes Namespaces Files Functions Variables
SimpleHogComparator.java
Go to the documentation of this file.
1 package cz.vutbr.feec.novak68.hogcomparators;
2
3 import cz.vutbr.feec.novak68.HOG;
4
8 public class SimpleHogComparator implements HOGComparator {
9
10 @Override
11 public double getDistance(HOG hog1, HOG hog2) {
12 double [] mse = new double[hog1.getCells()[0][0].length];
13 //compute MSE - Mean Square Error
14 // pro kazdy kos zvlaste
15 if (hogSizeEquals(hog1, hog2)) {
16 for (int a = 0; a < mse.length; a++) {
17 for (int x = 0; x < hog1.getCells().length; x++) {
18 for (int y = 0; y < hog1.getCells()[0].length; y++) {
19 mse[a]+=Math.pow((hog1.getMagnitude(x, y, a)-hog2.getMagnitude(x, y, a)), 2);
20 }
21 }
22 mse[a]=mse[a]/(hog1.getCells().length*hog1.getCells()[0].length);
23 }
24 }
25
26 // vysledek je prumer mse kazdeho kose
27 //RMSE = Root mean square deviation = sqrt(mse)
28 double rmse = 0;
29 for (int i=0;i<mse.length;i++)
30 rmse+= Math.sqrt(mse[i]);
31 rmse = rmse/hog1.getCells()[0][0].length;
32 return rmse;
33 }
34 private boolean hogSizeEquals(HOG hog1, HOG hog2){
35 if (hog1.getImageSize()[0] != hog2.getImageSize()[0] ||
36 hog1.getImageSize()[1] != hog2.getImageSize()[1] ||
37 hog1.getCells()[0][0].length != hog2.getCells()[0][0].length)
38 return false;
39 else
40 return true;
41 }
42 }
cz.vutbr.feec.novak68.HOG.getMagnitude
float getMagnitude(int x, int y, int angleBin)
Definition: HOG.java:342
cz.vutbr.feec.novak68.hogcomparators.SimpleHogComparator.getDistance
double getDistance(HOG hog1, HOG hog2)
Definition: SimpleHogComparator.java:11
cz.vutbr.feec.novak68.hogcomparators.SimpleHogComparator.hogSizeEquals
boolean hogSizeEquals(HOG hog1, HOG hog2)
Definition: SimpleHogComparator.java:34
cz.vutbr.feec.novak68.hogcomparators.HOGComparator
Definition: HOGComparator.java:9
cz.vutbr.feec.novak68.HOG.getImageSize
int[] getImageSize()
Definition: HOG.java:351
cz.vutbr.feec.novak68.HOG.getCells
float[][][] getCells()
Definition: HOG.java:345
cz.vutbr.feec.novak68.hogcomparators.SimpleHogComparator
Definition: SimpleHogComparator.java:8
cz.vutbr.feec.novak68.HOG
Definition: HOG.java:19