From 39fc9bbf36e317914f275489016418cac47e07ca Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 5 Mar 2022 16:57:28 +0100 Subject: [PATCH] improve formatting --- Image/BillDetection.h | 1 - Image/ImageUtils.h | 2 +- Image/Thresholding.h | 4 ++-- Tools/InvoicePreprocessing/main.cpp | 2 ++ 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Image/BillDetection.h b/Image/BillDetection.h index b3cf20b..79d54bf 100644 --- a/Image/BillDetection.h +++ b/Image/BillDetection.h @@ -70,7 +70,6 @@ namespace Image { cv::approxPolyDP(cv::Mat(contoursArea[i]), contoursDraw[i], 40, true); } - cv::Mat mask = cv::Mat(in.size(), CV_8UC3, cv::Scalar(255, 255, 255)); cv::drawContours(mask, contoursDraw, -1, cv::Scalar(0, 0, 0), cv::FILLED, 1); diff --git a/Image/ImageUtils.h b/Image/ImageUtils.h index d32c210..7f78a74 100644 --- a/Image/ImageUtils.h +++ b/Image/ImageUtils.h @@ -29,7 +29,7 @@ namespace Image { float lG = vG <= 0.04045 ? vG / 12.92 : pow(((vG + 0.055) / 1.055), 2.4); float lB = vB <= 0.04045 ? vB / 12.92 : pow(((vB + 0.055) / 1.055), 2.4); - float y = 0.2126 * lR + 0.7152 * lG + 0.0722 * lB; + float y = 0.2126 * lR + 0.7152 * lG + 0.0722 * lB; float lStar = y <= 216.0 / 24389.0 ? y * 24389.0 / 27.0 : pow(y, (1.0 / 3.0)) * 116.0 - 16.0; return lStar / 100.0; diff --git a/Image/Thresholding.h b/Image/Thresholding.h index 08517d4..2551c78 100644 --- a/Image/Thresholding.h +++ b/Image/Thresholding.h @@ -35,7 +35,7 @@ namespace Image { sum = 0.0; for (int j = 0; j < dim.height; ++j) { - bgr = in.at(j, i); + bgr = in.at(j, i); sum += Image::ImageUtils::lightnessFromRgb(bgr[2], bgr[1], bgr[0]); intImg[i][j] = i == 0 ? sum : intImg[i - 1][j] + sum; @@ -65,7 +65,7 @@ namespace Image { bgr = in.at(j, i); brightness = (float) Image::ImageUtils::lightnessFromRgb(bgr[2], bgr[1], bgr[0]); - color = brightness * count <= (sum * (100.0 - t) / 100.0) && brightness < 0.9 ? 0 : 255; + color = brightness * count <= (sum * (100.0 - t) / 100.0) && brightness < 0.95 ? 0 : 255; out.at(j, i)[0] = color; out.at(j, i)[1] = color; diff --git a/Tools/InvoicePreprocessing/main.cpp b/Tools/InvoicePreprocessing/main.cpp index 306a380..626a1ab 100644 --- a/Tools/InvoicePreprocessing/main.cpp +++ b/Tools/InvoicePreprocessing/main.cpp @@ -51,6 +51,8 @@ int main(int argc, char** argv) out = Image::Skew::deskewHoughLines(out); if (DEBUG) cv::imshow("rotation", out); + if (DEBUG) cv::imshow("original", in); + cv::imwrite(argv[2], out); if (DEBUG) cv::waitKey(0);