Adds preview functions
This commit is contained in:
+19
-4
@@ -32,6 +32,12 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//Function which should output some example(s) to file
|
||||
//that show how this descriptor works.
|
||||
virtual void preview(Image* img) {
|
||||
cout << "No preview defined. :-( " << endl;
|
||||
}
|
||||
|
||||
//Helper functions
|
||||
//TODO: Move these somewhere else. Maybe a friend-class?
|
||||
double* CalculateDCT(Image* img) {
|
||||
@@ -125,7 +131,7 @@ public:
|
||||
int green_b = (b << (64 - 16) >> (64 - 8)).to_ulong();
|
||||
int blue_b = (b << (64 - 8) >> (64 - 8)).to_ulong();
|
||||
return abs(red_a - red_b) + abs(green_a - green_b) + abs(blue_a - blue_b);
|
||||
};
|
||||
}
|
||||
string ToString() {
|
||||
return "averageColor";
|
||||
}
|
||||
@@ -332,7 +338,7 @@ public:
|
||||
if (a[i] != b[i]) biterror++;
|
||||
}
|
||||
return biterror;
|
||||
};
|
||||
}
|
||||
string ToString() {
|
||||
return "threshold";
|
||||
}
|
||||
@@ -365,10 +371,19 @@ public:
|
||||
if (a[i] != b[i]) biterror++;
|
||||
}
|
||||
return biterror;
|
||||
};
|
||||
}
|
||||
string ToString() {
|
||||
return "DCTPearson";
|
||||
}
|
||||
void preview(Image* img){
|
||||
Image* dct = new Image(*img);
|
||||
Image* local_image = new Image(*img);
|
||||
|
||||
//double* converted = CalculateDCsT(dct);
|
||||
local_image->type(GrayscaleType);
|
||||
local_image->sample(Geometry("8x8!")); //64 pixels
|
||||
local_image->write("DCTPearson.png");
|
||||
}
|
||||
};
|
||||
|
||||
class DCTMedian : public Descriptor {
|
||||
@@ -398,7 +413,7 @@ public:
|
||||
if (a[i] != b[i]) biterror++;
|
||||
}
|
||||
return biterror;
|
||||
};
|
||||
}
|
||||
string ToString() {
|
||||
return "DCTMedian";
|
||||
}
|
||||
|
||||
@@ -257,3 +257,13 @@ void DescriptorManager::outputRank(string imagename, int method) {
|
||||
cout << "(" << it->first << ", " << it->second << ")" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Just runs the preview functions of all the descriptors on given image.
|
||||
//No need to init before this.
|
||||
void DescriptorManager::generatePreviews(string imagename) {
|
||||
fs::path imagePath(img_path / imagename);
|
||||
Image* img = new Image(imagePath.generic_string());
|
||||
for (int i = 0; i < numDescriptors; i++) {
|
||||
descriptor_types[i]->preview(img);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -20,7 +20,9 @@ using namespace Magick;
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
//Manager class for
|
||||
//Manager class for descriptors.
|
||||
//Contains functions to load, store, process
|
||||
//all images, descriptors and mutations
|
||||
class DescriptorManager {
|
||||
public:
|
||||
DescriptorManager();
|
||||
@@ -30,6 +32,7 @@ public:
|
||||
void rankImages(string image_name, int method);
|
||||
multiset<pair<unsigned long long, string>> rankMutations(string image_name, int method);
|
||||
void runExperiments();
|
||||
void generatePreviews(string imagename);
|
||||
void outputMap(int a);
|
||||
void outputMap();
|
||||
void outputRank(string imagename, int method);
|
||||
|
||||
Reference in New Issue
Block a user