More migrations

This commit is contained in:
Mark Hoekveen
2019-06-21 16:44:00 +02:00
parent 9bde653a2a
commit 08e184f80d
+6 -50
View File
@@ -39,51 +39,6 @@ public:
}
//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.
@@ -135,7 +90,7 @@ public:
return "averageColor";
}
};
/*
//Counts the total number of colors
//and stores it in bit representation.
//Upper limit 16777216
@@ -143,7 +98,7 @@ public:
class numColors : public Descriptor {
public:
uint64_t feature(Image* img) {
return uint64_t(img->totalColors()-1);
return img->totalColors()-1;
}
string ToString() {
return "numColors";
@@ -181,13 +136,14 @@ public:
sort(intensities, intensities + numpixels);
//We know where the median is going to be:
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
for (ssize_t j = 0; j < m; j++) {
for (ssize_t i = 0; i < n; i++) {
retval <<= 1;
if (q[0] > intensity)
retval |= uint64_t(1);
//retval |= uint64_t(1);
retval++;
q = q + local_image->channels();
}
}
@@ -208,7 +164,7 @@ public:
return "median";
}
};
/*
//Sobel descriptor
//Calculates average intensity of the image with
//sobel convolution applied in both directions