From 704c83dd8d5c368c544e7fb9f088139dd90798c7 Mon Sep 17 00:00:00 2001 From: lltcggie Date: Sun, 27 Dec 2015 19:25:38 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=81=99=E3=82=8B=E3=83=A2?= =?UTF-8?q?=E3=83=87=E3=83=AB=E3=81=AB=E3=82=88=E3=81=A3=E3=81=A6=E3=81=AF?= =?UTF-8?q?2=E5=80=8D=E3=82=92=E8=B6=85=E3=81=88=E3=82=8B=E6=8B=A1?= =?UTF-8?q?=E5=A4=A7=E7=8E=87=E3=81=A7=E3=83=8E=E3=82=A4=E3=82=BA=E3=81=8C?= =?UTF-8?q?=E5=87=BA=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86=E3=81=AE=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20#7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/waifu2x.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/waifu2x.cpp b/common/waifu2x.cpp index 7f1fd12..32f42c2 100644 --- a/common/waifu2x.cpp +++ b/common/waifu2x.cpp @@ -1451,6 +1451,10 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructFloatMat(const bool isReconstructNois // パディングを取り払う im = im(cv::Rect(offset, offset, image_size.width, image_size.height)); + + // 値を0〜1にクリッピング + cv::threshold(im, im, 1.0, 1.0, cv::THRESH_TRUNC); + cv::threshold(im, im, 0.0, 0.0, cv::THRESH_TOZERO); } if (cancel_func && cancel_func()) @@ -1471,6 +1475,10 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructFloatMat(const bool isReconstructNois // パディングを取り払う im = im(cv::Rect(offset, offset, image_size.width, image_size.height)); + + // 値を0〜1にクリッピング + cv::threshold(im, im, 1.0, 1.0, cv::THRESH_TRUNC); + cv::threshold(im, im, 0.0, 0.0, cv::THRESH_TOZERO); } } @@ -1560,6 +1568,10 @@ Waifu2x::eWaifu2xError Waifu2x::Reconstruct(const bool isReconstructNoise, const cv::cvtColor(reconstruct_image, reconstruct_image, CV_RGB2GRAY); // この地点ではまだRGBなことに注意 } + // 値を0〜1にクリッピング + cv::threshold(reconstruct_image, reconstruct_image, 1.0, 1.0, cv::THRESH_TRUNC); + cv::threshold(reconstruct_image, reconstruct_image, 0.0, 0.0, cv::THRESH_TOZERO); + out = reconstruct_image; return eWaifu2xError_OK;