From 469ea42f49dc986d0bc507c5d6b1fa4adca0156d Mon Sep 17 00:00:00 2001 From: wisc Date: Sat, 2 Jan 2016 02:31:13 +0100 Subject: [PATCH] check for black pixel at center x/y Former-commit-id: d91f422f55638418d2517d91b1c925880d7ca448 --- include/blackborder/BlackBorderDetector.h | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/include/blackborder/BlackBorderDetector.h b/include/blackborder/BlackBorderDetector.h index c5ee91e7..3f190c5c 100644 --- a/include/blackborder/BlackBorderDetector.h +++ b/include/blackborder/BlackBorderDetector.h @@ -61,11 +61,51 @@ namespace hyperion template BlackBorder process(const Image & image) { + + // only test the topleft third of the image + int width = image.width() / 3; + int height = image.height() / 3; + int xCenter = image.width() / 2; + int yCenter = image.height() / 2; +// int maxSize = std::max(width, height); + + + + int firstNonBlackXPixelIndex = -1; + int firstNonBlackYPixelIndex = -1; + + // find first X pixel of the image + for (int x = 0; x < width; ++x) + { + const Pixel_T & color = image(x, yCenter); + if (!isBlack(color)) + { + firstNonBlackXPixelIndex = x; + break; + } + } + + // find first Y pixel of the image + for (int y = 0; y < height; ++y) + { + const Pixel_T & color = image(xCenter, y); + if (!isBlack(color)) + { + firstNonBlackYPixelIndex = y; + break; + } + } + + + +/* // only test the topleft third of the image int width = image.width() /3; int height = image.height() / 3; int maxSize = std::max(width, height); + + int firstNonBlackXPixelIndex = -1; int firstNonBlackYPixelIndex = -1; @@ -103,6 +143,7 @@ namespace hyperion break; } } +*/ // Construct result BlackBorder detectedBorder;