From 52ca17328b056e929c9b1f047688a1203e489e03 Mon Sep 17 00:00:00 2001 From: Julian Amann Date: Tue, 25 Jul 2017 12:02:59 +0200 Subject: [PATCH] Improved canonical include file of ImageProcessing lib. --- CMake/ProjectVersion.cmake | 2 +- Core/src/BlueFramework/Core/Version.h | 2 +- .../ImageProcessing/difference.cpp | 63 +++++++++---------- .../ImageProcessing/difference.h | 9 ++- include/buw.ImageProcessing.h | 5 ++ 5 files changed, 42 insertions(+), 39 deletions(-) diff --git a/CMake/ProjectVersion.cmake b/CMake/ProjectVersion.cmake index 0ed1f58..5a7e6cd 100644 --- a/CMake/ProjectVersion.cmake +++ b/CMake/ProjectVersion.cmake @@ -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") \ No newline at end of file diff --git a/Core/src/BlueFramework/Core/Version.h b/Core/src/BlueFramework/Core/Version.h index 858ce0d..789b56e 100644 --- a/Core/src/BlueFramework/Core/Version.h +++ b/Core/src/BlueFramework/Core/Version.h @@ -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 diff --git a/ImageProcessing/src/BlueFramework/ImageProcessing/difference.cpp b/ImageProcessing/src/BlueFramework/ImageProcessing/difference.cpp index 5ddd457..6383da0 100644 --- a/ImageProcessing/src/BlueFramework/ImageProcessing/difference.cpp +++ b/ImageProcessing/src/BlueFramework/ImageProcessing/difference.cpp @@ -21,27 +21,26 @@ BLUEFRAMEWORK_IMAGEPROCESSING_NAMESPACE_BEGIN -bool areEqual( - buw::ReferenceCounted a, - buw::ReferenceCounted 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; } } @@ -49,20 +48,20 @@ bool areEqual( return true; } -buw::ReferenceCounted createDifferenceImage(buw::ReferenceCounted a, buw::ReferenceCounted b, const std::uint8_t color[3]) { - buw::ReferenceCounted tmp = std::make_shared(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)); } } } @@ -70,17 +69,17 @@ buw::ReferenceCounted createDifferenceImage(buw::ReferenceCounted createDifferenceImage(buw::ReferenceCounted a, buw::ReferenceCounted b, const float color[4]) { - buw::ReferenceCounted tmp = std::make_shared(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); @@ -91,15 +90,15 @@ buw::ReferenceCounted createDifferenceImage(buw::ReferenceCounted highlightDifferences(buw::ReferenceCounted a, buw::ReferenceCounted b, const Color3b color) { - buw::ReferenceCounted tmp = std::make_shared(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)); } } } diff --git a/ImageProcessing/src/BlueFramework/ImageProcessing/difference.h b/ImageProcessing/src/BlueFramework/ImageProcessing/difference.h index 8b24701..96c9437 100644 --- a/ImageProcessing/src/BlueFramework/ImageProcessing/difference.h +++ b/ImageProcessing/src/BlueFramework/ImageProcessing/difference.h @@ -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 a, buw::ReferenceCounted b); -buw::ReferenceCounted highlightDifferences(buw::ReferenceCounted a, buw::ReferenceCounted b, const Color3b color); -buw::ReferenceCounted createDifferenceImage(buw::ReferenceCounted a, buw::ReferenceCounted b, const float Color[4]); -buw::ReferenceCounted createDifferenceImage(buw::ReferenceCounted a, buw::ReferenceCounted 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 diff --git a/include/buw.ImageProcessing.h b/include/buw.ImageProcessing.h index 21091b5..ccea2fe 100644 --- a/include/buw.ImageProcessing.h +++ b/include/buw.ImageProcessing.h @@ -19,5 +19,10 @@ // Canonical include file - idea taken from https://anteru.net/blog/2012/03/16/1871/index.html #pragma once +#include +#include +#include #include +#include #include +#include