2017-07-23 22:53:02 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
2017-08-06 19:12:44 +00:00
|
|
|
#include "color.h"
|
|
|
|
|
#include "colorchecker.h"
|
|
|
|
|
#include "colors.h"
|
2017-08-06 19:39:11 +00:00
|
|
|
#include "coord.h"
|
|
|
|
|
#include "image.h"
|
|
|
|
|
#include "piraw.h"
|
|
|
|
|
#include "util.h"
|
2017-07-23 22:53:02 +00:00
|
|
|
|
|
|
|
|
int main() {
|
2017-08-06 19:55:31 +00:00
|
|
|
auto image = PiRaw2::FromJpeg(ReadFile("test.jpg"));
|
2017-08-06 19:39:11 +00:00
|
|
|
auto closest = ColorCheckerClosest(*image);
|
2017-08-06 19:12:44 +00:00
|
|
|
for (uint32_t cc = 0; cc < kColorCheckerSrgb.size(); ++cc) {
|
2017-08-06 05:17:21 +00:00
|
|
|
const auto& coord = closest.at(cc);
|
|
|
|
|
const auto& color = kColorCheckerSrgb.at(cc);
|
|
|
|
|
std::cout << cc << ": " << coord << " difference=" << color.Difference(image->GetPixel(coord)) << std::endl;
|
|
|
|
|
image->DrawSquare({std::max(5U, coord.x) - 5, std::max(5U, coord.y) - 5}, kBlack, 10);
|
|
|
|
|
image->DrawSquare({std::max(6U, coord.x) - 6, std::max(6U, coord.y) - 6}, color, 12);
|
|
|
|
|
image->DrawSquare({std::max(7U, coord.x) - 7, std::max(7U, coord.y) - 7}, color, 14);
|
|
|
|
|
image->DrawSquare({std::max(8U, coord.x) - 8, std::max(8U, coord.y) - 8}, color, 16);
|
|
|
|
|
image->DrawSquare({std::max(9U, coord.x) - 9, std::max(9U, coord.y) - 9}, kWhite, 18);
|
2017-08-06 00:05:37 +00:00
|
|
|
}
|
2017-08-06 19:55:31 +00:00
|
|
|
WriteFile("test.png", image->ToPng());
|
2017-07-23 22:53:02 +00:00
|
|
|
}
|