I am trying to create a Content Based Image Retrieval system. I have implemented the skewness algorithm below. I am measuring the performance of my system with precision and recall. But I have been told my precision and recall results look strange and that my code could be incorrect. I have checked and checked it time and time and again and I can not get my head around what is wrong. I am at the stage now where I need a fresh pair of eyes over it.
Could someone have a look at the code and perhaps tell me what is wrong? I am not sure if this is even the right place to ask a question like this but as you can tell, I am out of options.
/*Mean Red*/
public static double meanValueRed(BufferedImage image) {
double sum = 0.0;
Color r = new Color(image.getRGB(0, 0));
for (int y = 0; y < image.getHeight(); ++y){
for (int x = 0; x < image.getWidth(); ++x){
sum += r.getRed();
}
}
retu sum / (image.getWidth() * image.getHeight());
}
/*Mean Green*/
public static double meanValueGreen(BufferedImage image) {
double sum = 0.0;
Color r = new Color(image.getRGB(0, 0));
for (int y = 0; y < image.getHeight(); ++y){
for (int x = 0; x < image.getWidth(); ++x){
sum += r.getGreen();
}
}
retu sum / (image.getWidth() * image.getHeight());
}
/*Mean Blue*/
public static double meanValueBlue(BufferedImage image) {
double sum = 0.0;
Color r = new Color(image.getRGB(0, 0));
for (int y = 0; y < image.getHeight(); ++y){
for (int x = 0; x < image.getWidth(); ++x){
sum += r.getBlue();
}
}
retu sum / (image.getWidth() * image.getHeight());
}
/* RGB Colour Mean */
public static double rgbMean(BufferedImage image) {
retu (meanValueRed(image) + meanValueGreen(image) + meanValueBlue(image)) / 3;
}
/*Red Variance*/
public static double varianceRed(BufferedImage image){
double mean = meanValueRed(image);
double sumOfDiff = 0.0;
for (int y = 0; y < image.getHeight(); ++y){
for (int x = 0; x < image.getWidth(); ++x){
Color r = new Color(image.getRGB(x, y));
double colour = r.getRed() - mean;
sumOfDiff += Math.abs(Math.pow(colour, 3));
}
}
retu sumOfDiff / ((image.getWidth() * image.getHeight()) - 1);
}
/*Red Standard Deviation*/
public static double standardDeviationRed(BufferedImage image){
retu Math.sqrt(varianceBlue(image));
}
/*Green Variance*/
public static double varianceGreen(BufferedImage image){
double mean = meanValueGreen(image);
double sumOfDiff = 0.0;
for (int y = 0; y < image.getHeight(); ++y){
for (int x = 0; x < image.getWidth(); ++x){
Color g = new Color(image.getRGB(x, y));
double colour= g.getGreen() - mean;
sumOfDiff += Math.abs(Math.pow(colour, 3));
}
}
retu sumOfDiff / ((image.getWidth() * image.getHeight()) - 1);
}
/*Green Standard Deviation*/
public static double standardDeviationGreen(BufferedImage image){
retu Math.sqrt(varianceBlue(image));
}
/*Blue Variance*/
public static double varianceBlue(BufferedImage image){
double mean = meanValueBlue(image);
double sumOfDiff = 0.0;
for (int y = 0; y < image.getHeight(); ++y){
for (int x = 0; x < image.getWidth(); ++x){
Color g = new Color(image.getRGB(x, y));
double colour= g.getBlue() - mean;
sumOfDiff += Math.abs(Math.pow(colour, 3));
}
}
retu sumOfDiff / ((image.getWidth() * image.getHeight()) - 1);
}
/*Blue Standard Deviation*/
public static double standardDeviationBlue(BufferedImage image){
retu Math.sqrt(varianceBlue(image));
}
