使用するモデルによっては2倍を超える拡大率でノイズが出てしまうのを修正 #7

This commit is contained in:
lltcggie 2015-12-27 19:25:38 +09:00
parent 6ac091fbe2
commit 704c83dd8d

View File

@ -1451,6 +1451,10 @@ Waifu2x::eWaifu2xError Waifu2x::ReconstructFloatMat(const bool isReconstructNois
// パディングを取り払う // パディングを取り払う
im = im(cv::Rect(offset, offset, image_size.width, image_size.height)); im = im(cv::Rect(offset, offset, image_size.width, image_size.height));
// 値を01にクリッピング
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()) 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)); im = im(cv::Rect(offset, offset, image_size.width, image_size.height));
// 値を01にクリッピング
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なことに注意 cv::cvtColor(reconstruct_image, reconstruct_image, CV_RGB2GRAY); // この地点ではまだRGBなことに注意
} }
// 値を01にクリッピング
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; out = reconstruct_image;
return eWaifu2xError_OK; return eWaifu2xError_OK;