More migrations
This commit is contained in:
+6
-50
@@ -39,51 +39,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Helper functions
|
//Helper functions
|
||||||
//TODO: Move these somewhere else. Maybe a friend-class?
|
|
||||||
// double* CalculateDCT(Image* img) {
|
|
||||||
// double pi = 3.14159265359;
|
|
||||||
// img->type(GrayscaleType);
|
|
||||||
// img->sample(Geometry("8x8!")); //64 pixels
|
|
||||||
// ssize_t n = 8;
|
|
||||||
// ssize_t m = 8;
|
|
||||||
// Pixels view(*img);
|
|
||||||
// int chan = (int)img->channels(); //should be 1, just intensity
|
|
||||||
// const Quantum *p = view.getConst(0, 0, n, m); //entire image
|
|
||||||
// uint64_t retval(0);
|
|
||||||
// int N = n*m;
|
|
||||||
// Image* newimg = new Image(Geometry(n, m), Color("white"));
|
|
||||||
// newimg->type(GrayscaleType);
|
|
||||||
// Pixels conview(*newimg);
|
|
||||||
// Quantum *c = conview.get(0, 0, n, m); //entire converted image
|
|
||||||
|
|
||||||
// static double converted[64];
|
|
||||||
// double* q = converted;
|
|
||||||
// for (ssize_t j = 0; j < m; j++) {
|
|
||||||
// for (ssize_t i = 0; i < n; i++) {
|
|
||||||
// double sum = 0;
|
|
||||||
// int k = (j*m) + i;
|
|
||||||
// const Quantum *p_s = view.getConst(0, 0, n, m); //entire image
|
|
||||||
// for (ssize_t x = 0; x < m; x++) {
|
|
||||||
// for (ssize_t y = 0; y < n; y++) {
|
|
||||||
// int n = (x*m) + y;
|
|
||||||
// double pixel = ((double)p_s[0] / QuantumRange); //rescaled to [0..1]
|
|
||||||
// sum += pixel * std::cos((pi / N)*(n + 0.5)*k);
|
|
||||||
// p_s = p_s + chan;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// q[0] = sum;
|
|
||||||
// q = q++;
|
|
||||||
// p = p + chan;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// for (int i = 0; i < 64; i++) {
|
|
||||||
// c[0] = converted[i] * 255.0;
|
|
||||||
// c++;
|
|
||||||
// }
|
|
||||||
// delete newimg;
|
|
||||||
// //newimg->write("Out.png"); //for debugging purposes
|
|
||||||
// return converted;
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Average color of the image.
|
//Average color of the image.
|
||||||
@@ -135,7 +90,7 @@ public:
|
|||||||
return "averageColor";
|
return "averageColor";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/*
|
|
||||||
//Counts the total number of colors
|
//Counts the total number of colors
|
||||||
//and stores it in bit representation.
|
//and stores it in bit representation.
|
||||||
//Upper limit 16777216
|
//Upper limit 16777216
|
||||||
@@ -143,7 +98,7 @@ public:
|
|||||||
class numColors : public Descriptor {
|
class numColors : public Descriptor {
|
||||||
public:
|
public:
|
||||||
uint64_t feature(Image* img) {
|
uint64_t feature(Image* img) {
|
||||||
return uint64_t(img->totalColors()-1);
|
return img->totalColors()-1;
|
||||||
}
|
}
|
||||||
string ToString() {
|
string ToString() {
|
||||||
return "numColors";
|
return "numColors";
|
||||||
@@ -181,13 +136,14 @@ public:
|
|||||||
sort(intensities, intensities + numpixels);
|
sort(intensities, intensities + numpixels);
|
||||||
//We know where the median is going to be:
|
//We know where the median is going to be:
|
||||||
intensity = (float)(intensities[31] + intensities[32]) / 2;
|
intensity = (float)(intensities[31] + intensities[32]) / 2;
|
||||||
uint64_t retval(0);
|
uint64_t retval = 0;
|
||||||
const Quantum *q = view.getConst(0, 0, n, m); //entire image
|
const Quantum *q = view.getConst(0, 0, n, m); //entire image
|
||||||
for (ssize_t j = 0; j < m; j++) {
|
for (ssize_t j = 0; j < m; j++) {
|
||||||
for (ssize_t i = 0; i < n; i++) {
|
for (ssize_t i = 0; i < n; i++) {
|
||||||
retval <<= 1;
|
retval <<= 1;
|
||||||
if (q[0] > intensity)
|
if (q[0] > intensity)
|
||||||
retval |= uint64_t(1);
|
//retval |= uint64_t(1);
|
||||||
|
retval++;
|
||||||
q = q + local_image->channels();
|
q = q + local_image->channels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,7 +164,7 @@ public:
|
|||||||
return "median";
|
return "median";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
//Sobel descriptor
|
//Sobel descriptor
|
||||||
//Calculates average intensity of the image with
|
//Calculates average intensity of the image with
|
||||||
//sobel convolution applied in both directions
|
//sobel convolution applied in both directions
|
||||||
|
|||||||
Reference in New Issue
Block a user