From 6feda47e6108a240a503d955640fe858e3f00946 Mon Sep 17 00:00:00 2001 From: lltcggie Date: Sun, 6 Dec 2015 03:56:33 +0900 Subject: [PATCH] =?UTF-8?q?Y=E3=83=A2=E3=83=87=E3=83=AB=E3=81=A7=E8=87=B4?= =?UTF-8?q?=E5=91=BD=E7=9A=84=E3=81=AA=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C?= =?UTF-8?q?=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/waifu2x.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/common/waifu2x.cpp b/common/waifu2x.cpp index 93afec2..9e11ed1 100644 --- a/common/waifu2x.cpp +++ b/common/waifu2x.cpp @@ -381,14 +381,19 @@ Waifu2x::eWaifu2xError Waifu2x::LoadMatBySTBI(cv::Mat &float_image, const std::s // 画像から輝度の画像を取り出す Waifu2x::eWaifu2xError Waifu2x::CreateBrightnessImage(const cv::Mat &float_image, cv::Mat &im) { - cv::Mat converted_color; - cv::cvtColor(float_image, converted_color, ConvertMode); + if (float_image.channels() > 1) + { + cv::Mat converted_color; + cv::cvtColor(float_image, converted_color, ConvertMode); - std::vector planes; - cv::split(converted_color, planes); + std::vector planes; + cv::split(converted_color, planes); - im = planes[0]; - planes.clear(); + im = planes[0]; + planes.clear(); + } + else + im = float_image; return eWaifu2xError_OK; }