Adds Crop and Watermark mutations
This commit is contained in:
@@ -20,12 +20,13 @@ DescriptorManager::DescriptorManager(const fs::path & image_path) {
|
|||||||
descriptor_types[0] = new averageColor();
|
descriptor_types[0] = new averageColor();
|
||||||
|
|
||||||
mutators[0] = new Grayscale();
|
mutators[0] = new Grayscale();
|
||||||
mutators[1] = new Flip();
|
mutators[1] = new Crop();
|
||||||
mutators[2] = new Flop();
|
mutators[2] = new Flop();
|
||||||
mutators[3] = new JPEG();
|
mutators[3] = new JPEG();
|
||||||
mutators[4] = new LowQ();
|
mutators[4] = new LowQ();
|
||||||
mutators[5] = new Hue();
|
mutators[5] = new Hue();
|
||||||
mutators[6] = new Brighten();
|
mutators[6] = new Brighten();
|
||||||
|
mutators[7] = new Watermark();
|
||||||
}
|
}
|
||||||
|
|
||||||
//No need to call destructor.. yet?
|
//No need to call destructor.. yet?
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ public:
|
|||||||
void outputRank(string imagename, int method);
|
void outputRank(string imagename, int method);
|
||||||
private:
|
private:
|
||||||
static const int numDescriptors = 8;
|
static const int numDescriptors = 8;
|
||||||
static const int numMutations = 7;
|
static const int numMutations = 8;
|
||||||
//TODO: automagically update this?
|
//TODO: automagically update this?
|
||||||
|
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|||||||
+37
@@ -102,3 +102,40 @@ public:
|
|||||||
return "Brighten";
|
return "Brighten";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//shaves off some pixels from the bottomright edge of the image
|
||||||
|
class Crop : public Mutation {
|
||||||
|
public:
|
||||||
|
Image * getMutated(Image* img) {
|
||||||
|
Image* mut = new Image(*img);
|
||||||
|
ssize_t n = mut->rows();
|
||||||
|
ssize_t m = mut->columns();
|
||||||
|
float shave = 0.1;
|
||||||
|
n *= 1.0 - shave;
|
||||||
|
m *= 1.0 - shave;
|
||||||
|
mut->crop(Geometry(m, n, 0, 0));
|
||||||
|
return mut;
|
||||||
|
}
|
||||||
|
string ToString() {
|
||||||
|
return "Crop";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//Adds a logo to the top-left corner of the image
|
||||||
|
class Watermark : public Mutation {
|
||||||
|
public:
|
||||||
|
Watermark() {
|
||||||
|
watermark = new Image;
|
||||||
|
watermark->read("watermark.png");
|
||||||
|
}
|
||||||
|
Image * getMutated(Image* img) {
|
||||||
|
Image* mut = new Image(*img);
|
||||||
|
mut->composite(*watermark, "+10+10", OverCompositeOp);
|
||||||
|
return mut;
|
||||||
|
}
|
||||||
|
string ToString() {
|
||||||
|
return "Watermark";
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Image* watermark;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user