-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
593c336
commit cc8ea4b
Showing
14 changed files
with
203 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,5 @@ src/protobuf/** | |
ehthumbs.db | ||
Thumbs.db | ||
|
||
filter_test_input | ||
filter_test_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Created by clemens on 18.06.19. | ||
// | ||
|
||
#include "BasicImageFilter.h" | ||
|
||
using namespace selfomat::logic; | ||
|
||
void BasicImageFilter::processImage(Magick::Image &image, double gain) { | ||
image.normalize(); | ||
image.autoGamma(); | ||
|
||
image.sigmoidalContrast(0, interpolate(1.0, 2.5, gain)); | ||
|
||
image.modulate(interpolate(100.0, 120.0, gain), | ||
interpolate(100.0, 120.0, gain), | ||
100.0); | ||
} | ||
|
||
std::string BasicImageFilter::getName() { | ||
return "basic_image_filter"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// Created by clemens on 18.06.19. | ||
// | ||
|
||
#ifndef SELF_O_MAT_BASICIMAGEFILTER_H | ||
#define SELF_O_MAT_BASICIMAGEFILTER_H | ||
|
||
|
||
#include "IImageFilter.h" | ||
|
||
namespace selfomat { | ||
namespace logic { | ||
class BasicImageFilter : public IImageFilter { | ||
public: | ||
std::string getName() override; | ||
|
||
void processImage(Magick::Image &image, double gain) override; | ||
}; | ||
|
||
} | ||
} | ||
|
||
|
||
#endif //SELF_O_MAT_BASICIMAGEFILTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// | ||
// Created by clemens on 18.06.19. | ||
// | ||
|
||
#include "IImageFilter.h" | ||
|
||
double selfomat::logic::IImageFilter::interpolate(double min, double max, double percentage) { | ||
return (max - min)*percentage + min; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// Created by clemens on 18.06.19. | ||
// | ||
|
||
#ifndef SELF_O_MAT_IIMAGEFILTER_H | ||
#define SELF_O_MAT_IIMAGEFILTER_H | ||
|
||
#include <Magick++.h> | ||
#include <Magick++/Image.h> | ||
|
||
|
||
namespace selfomat { | ||
namespace logic { | ||
class IImageFilter { | ||
protected: | ||
double interpolate(double min, double max, double percentage); | ||
public: | ||
virtual std::string getName() = 0; | ||
virtual void processImage(Magick::Image &image, double gain) = 0; | ||
}; | ||
} | ||
} | ||
|
||
|
||
#endif //SELF_O_MAT_IIMAGEFILTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <vector> | ||
#include <logic/IImageFilter.h> | ||
#include <logic/BasicImageFilter.h> | ||
#include <iostream> | ||
#include <boost/filesystem.hpp> | ||
#include <string> | ||
|
||
using namespace selfomat::logic; | ||
using namespace boost::filesystem; | ||
|
||
int main(int argc, char *argv[]) { | ||
|
||
if(argc != 2) { | ||
std::cout << "Usage: ./filter_test <image in dir> <image out dir>" << std::endl; | ||
return 1; | ||
} | ||
|
||
std::vector<IImageFilter*> filters; | ||
filters.push_back(new BasicImageFilter()); | ||
|
||
path p(argv[1]); | ||
directory_iterator end_itr; | ||
|
||
path out_dir("filter_test_output"); | ||
|
||
system("rm -rf ./filter_test_output"); | ||
|
||
create_directories(out_dir); | ||
|
||
|
||
|
||
// cycle through the directory | ||
int imageIndex = 0; | ||
for (directory_iterator itr(p); itr != end_itr; ++itr) | ||
{ | ||
if (is_regular_file(itr->path())) { | ||
imageIndex++; | ||
std::string current_file = itr->path().string(); | ||
std::cout << current_file << std::endl; | ||
|
||
// Load file into image magick | ||
Magick::Image image; | ||
|
||
|
||
for(auto &filter : filters) { | ||
for(double d = 0.0; d <= 1.0; d+=0.25) { | ||
image.read(current_file); | ||
image.resize(Magick::Geometry(1000, 1000)); | ||
image.write("scaled.jpg"); | ||
filter->processImage(image, d); | ||
image.write("filtered.jpg"); | ||
std::string outfile = | ||
out_dir.string() + "/" + std::to_string(imageIndex) + "_" + filter->getName() + "_" + std::to_string((int)(d*100)) + | ||
itr->path().extension().string(); | ||
system((std::string("convert +append scaled.jpg filtered.jpg ") + outfile).c_str()); | ||
//system((std::string("mv filtered.jpg ")+outfile).c_str()); | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |