Skip to content

Commit

Permalink
Improved canonical include file of ImageProcessing lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vertexwahn committed Jul 25, 2017
1 parent c6b5b10 commit 52ca173
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 39 deletions.
2 changes: 1 addition & 1 deletion CMake/ProjectVersion.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(PROJECT_VERSION_TWEAK "50")
set(PROJECT_VERSION_TWEAK "51")
set(PROJECT_VERSION_PATCH "1")
set(PROJECT_VERSION_MINOR "1")
set(PROJECT_VERSION_MAJOR "3")
2 changes: 1 addition & 1 deletion Core/src/BlueFramework/Core/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define BLUEFRAMEWORK_API_MAJOR 3
#define BLUEFRAMEWORK_API_MINOR 1
#define BLUEFRAMEWORK_API_PATCH 1
#define BLUEFRAMEWORK_API_TWEAK 50
#define BLUEFRAMEWORK_API_TWEAK 51

BLUEFRAMEWORK_CORE_NAMESPACE_BEGIN

Expand Down
63 changes: 31 additions & 32 deletions ImageProcessing/src/BlueFramework/ImageProcessing/difference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,66 +21,65 @@

BLUEFRAMEWORK_IMAGEPROCESSING_NAMESPACE_BEGIN

bool areEqual(
buw::ReferenceCounted<Image4f> a,
buw::ReferenceCounted<Image4f> b)
bool areEqual(const Image4f& a,
const Image4f& b)
{
BLUE_ASSERT(a->getWidth() == b->getWidth(), "different widths");
BLUE_ASSERT(a->getHeight() == b->getHeight(), "different heights");
BLUE_ASSERT(a.getWidth() == b.getWidth(), "different widths");
BLUE_ASSERT(a.getHeight() == b.getHeight(), "different heights");

if (a->getWidth() != b->getWidth() ||
a->getHeight() != b->getHeight())
if (a.getWidth() != b.getWidth() ||
a.getHeight() != b.getHeight())
{
return false;
}

int width = a->getWidth();
int height = a->getHeight();
int width = a.getWidth();
int height = a.getHeight();

for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
if (a->getPixelColor(x, y) != b->getPixelColor(x, y))
if (a.getPixelColor(x, y) != b.getPixelColor(x, y))
return false;
}
}

return true;
}

buw::ReferenceCounted<Image3b> createDifferenceImage(buw::ReferenceCounted<Image3b> a, buw::ReferenceCounted<Image3b> b, const std::uint8_t color[3]) {
buw::ReferenceCounted<Image3b> tmp = std::make_shared<Image3b>(a->getWidth(), b->getHeight());
Image3b createDifferenceImage(const Image3b& a, const Image3b& b, const std::uint8_t color[3]) {
Image3b tmp(a.getWidth(), b.getHeight());

for (int y = 0; y < a->getHeight(); y++) {
for (int x = 0; x < a->getWidth(); x++) {
if (a->getPixelColor(x, y) != b->getPixelColor(x, y)) {
for (int y = 0; y < a.getHeight(); y++) {
for (int x = 0; x < a.getWidth(); x++) {
if (a.getPixelColor(x, y) != b.getPixelColor(x, y)) {
if (color) {
tmp->setPixelColor(x, y, buw::Color3b(color[0], color[1], color[2]));
tmp.setPixelColor(x, y, buw::Color3b(color[0], color[1], color[2]));
} else {
tmp->setPixelColor(x, y, buw::Color3b(255, 0, 0));
tmp.setPixelColor(x, y, buw::Color3b(255, 0, 0));
}

} else {
tmp->setPixelColor(x, y, a->getPixelColor(x, y));
tmp.setPixelColor(x, y, a.getPixelColor(x, y));
}
}
}

return tmp;
}

buw::ReferenceCounted<Image4f> createDifferenceImage(buw::ReferenceCounted<Image4f> a, buw::ReferenceCounted<Image4f> b, const float color[4]) {
buw::ReferenceCounted<Image4f> tmp = std::make_shared<Image4f>(a->getWidth(), b->getHeight());
Image4f createDifferenceImage(const Image4f& a, const Image4f& b, const float color[4]) {
Image4f tmp(a.getWidth(), b.getHeight());

for (int y = 0; y < a->getHeight(); y++) {
for (int x = 0; x < a->getWidth(); x++) {
auto ca = a->getPixelColor(x, y);
auto cb = b->getPixelColor(x, y);
for (int y = 0; y < a.getHeight(); y++) {
for (int x = 0; x < a.getWidth(); x++) {
auto ca = a.getPixelColor(x, y);
auto cb = b.getPixelColor(x, y);
auto diff = ca - cb;

if (ca != cb) {
tmp->setPixelColor(x, y, Color4f(color[0], color[1], color[2], color[3]));
tmp.setPixelColor(x, y, Color4f(color[0], color[1], color[2], color[3]));
}

//diff = Color4f(std::abs(diff.r), std::abs(diff.g), std::abs(diff.b), 1.0f);
Expand All @@ -91,15 +90,15 @@ buw::ReferenceCounted<Image4f> createDifferenceImage(buw::ReferenceCounted<Image
return tmp;
}

buw::ReferenceCounted<BlueFramework::ImageProcessing::Image3b> highlightDifferences(buw::ReferenceCounted<Image3b> a, buw::ReferenceCounted<Image3b> b, const Color3b color) {
buw::ReferenceCounted<Image3b> tmp = std::make_shared<Image3b>(a->getWidth(), b->getHeight());
Image3b highlightDifferences(const Image3b& a, const Image3b& b, const Color3b color) {
Image3b tmp(a.getWidth(), b.getHeight());

for (int y = 0; y < a->getHeight(); y++) {
for (int x = 0; x < a->getWidth(); x++) {
if (a->getPixelColor(x, y) != b->getPixelColor(x, y)) {
tmp->setPixelColor(x, y, color);
for (int y = 0; y < a.getHeight(); y++) {
for (int x = 0; x < a.getWidth(); x++) {
if (a.getPixelColor(x, y) != b.getPixelColor(x, y)) {
tmp.setPixelColor(x, y, color);
} else {
tmp->setPixelColor(x, y, Color3b(0, 0, 0));
tmp.setPixelColor(x, y, Color3b(0, 0, 0));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
#ifndef BlueFramework_ImageProcessing_difference_91e49169_661c_4f4c_9c07_6588d56c1f01_h
#define BlueFramework_ImageProcessing_difference_91e49169_661c_4f4c_9c07_6588d56c1f01_h

#include "BlueFramework/Core/memory.h"
#include "BlueFramework/ImageProcessing/Image.h"
#include "BlueFramework/ImageProcessing/namespace.h"

BLUEFRAMEWORK_IMAGEPROCESSING_NAMESPACE_BEGIN

bool areEqual(buw::ReferenceCounted<Image4f> a, buw::ReferenceCounted<Image4f> b);
buw::ReferenceCounted<Image3b> highlightDifferences(buw::ReferenceCounted<Image3b> a, buw::ReferenceCounted<Image3b> b, const Color3b color);
buw::ReferenceCounted<Image4f> createDifferenceImage(buw::ReferenceCounted<Image4f> a, buw::ReferenceCounted<Image4f> b, const float Color[4]);
buw::ReferenceCounted<Image3b> createDifferenceImage(buw::ReferenceCounted<Image3b> a, buw::ReferenceCounted<Image3b> b, const std::uint8_t color[3]);
bool areEqual(const Image4f& a, const Image4f& b);
Image3b highlightDifferences(const Image3b& a, const Image3b& b, const Color3b color);
Image4f createDifferenceImage(const Image4f& a, const Image4f& b, const float Color[4]);
Image3b createDifferenceImage(const Image3b& a, const Image3b& b, const std::uint8_t color[3]);

BLUEFRAMEWORK_IMAGEPROCESSING_NAMESPACE_END

Expand Down
5 changes: 5 additions & 0 deletions include/buw.ImageProcessing.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@
// Canonical include file - idea taken from https://anteru.net/blog/2012/03/16/1871/index.html
#pragma once

#include <BlueFramework/ImageProcessing/captureScreen.h>
#include <BlueFramework/ImageProcessing/difference.h>
#include <BlueFramework/ImageProcessing/findSubimage.h>
#include <BlueFramework/ImageProcessing/Image.h>
#include <BlueFramework/ImageProcessing/ImageFilter.h>
#include <BlueFramework/ImageProcessing/io.h>
#include <BlueFramework/ImageProcessing/proceduralTextureGeneration.h>

0 comments on commit 52ca173

Please sign in to comment.