mirror of
https://github.com/lltcggie/waifu2x-caffe.git
synced 2025-06-26 13:42:48 +00:00
ノイズ除去モードで致命的なエラーが発生するのを修正
This commit is contained in:
parent
3941c5362c
commit
8c2b96df61
@ -1293,7 +1293,7 @@ Waifu2x::eWaifu2xError Waifu2x::Reconstruct(const bool isReconstructNoise, const
|
|||||||
return eWaifu2xError_OK;
|
return eWaifu2xError_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Waifu2x::eWaifu2xError Waifu2x::AfterReconstructFloatMatProcess(const waifu2xCancelFunc cancel_func, const cv::Mat &floatim, const cv::Mat &in, cv::Mat &out)
|
Waifu2x::eWaifu2xError Waifu2x::AfterReconstructFloatMatProcess(const bool isReconstructScale, const waifu2xCancelFunc cancel_func, const cv::Mat &floatim, const cv::Mat &in, cv::Mat &out)
|
||||||
{
|
{
|
||||||
cv::Size_<int> image_size = in.size();
|
cv::Size_<int> image_size = in.size();
|
||||||
|
|
||||||
@ -1329,7 +1329,7 @@ Waifu2x::eWaifu2xError Waifu2x::AfterReconstructFloatMatProcess(const waifu2xCan
|
|||||||
const double shrinkRatio = scale_ratio / std::pow(2.0, (double)scale2);
|
const double shrinkRatio = scale_ratio / std::pow(2.0, (double)scale2);
|
||||||
|
|
||||||
cv::Mat alpha;
|
cv::Mat alpha;
|
||||||
if (floatim.channels() == 4 && scale2 >= 1)
|
if (floatim.channels() == 4 && isReconstructScale)
|
||||||
{
|
{
|
||||||
std::vector<cv::Mat> planes;
|
std::vector<cv::Mat> planes;
|
||||||
cv::split(floatim, planes);
|
cv::split(floatim, planes);
|
||||||
@ -1357,9 +1357,12 @@ Waifu2x::eWaifu2xError Waifu2x::AfterReconstructFloatMatProcess(const waifu2xCan
|
|||||||
cv::merge(planes, process_image);
|
cv::merge(planes, process_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isReconstructScale)
|
||||||
|
{
|
||||||
const cv::Size_<int> ns(image_size.width * shrinkRatio, image_size.height * shrinkRatio);
|
const cv::Size_<int> ns(image_size.width * shrinkRatio, image_size.height * shrinkRatio);
|
||||||
if (image_size.width != ns.width || image_size.height != ns.height)
|
if (image_size.width != ns.width || image_size.height != ns.height)
|
||||||
cv::resize(process_image, process_image, ns, 0.0, 0.0, cv::INTER_LINEAR);
|
cv::resize(process_image, process_image, ns, 0.0, 0.0, cv::INTER_LINEAR);
|
||||||
|
}
|
||||||
|
|
||||||
out = process_image;
|
out = process_image;
|
||||||
|
|
||||||
@ -1392,7 +1395,7 @@ Waifu2x::eWaifu2xError Waifu2x::waifu2x(const std::string &input_file, const std
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
cv::Mat process_image;
|
cv::Mat process_image;
|
||||||
ret = AfterReconstructFloatMatProcess(cancel_func, float_image, reconstruct_image, process_image);
|
ret = AfterReconstructFloatMatProcess(isReconstructScale, cancel_func, float_image, reconstruct_image, process_image);
|
||||||
if (ret != eWaifu2xError_OK)
|
if (ret != eWaifu2xError_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ private:
|
|||||||
eWaifu2xError BeforeReconstructFloatMatProcess(const cv::Mat &in, cv::Mat &out, bool &convertBGRflag);
|
eWaifu2xError BeforeReconstructFloatMatProcess(const cv::Mat &in, cv::Mat &out, bool &convertBGRflag);
|
||||||
eWaifu2xError ReconstructFloatMat(const bool isReconstructNoise, const bool isReconstructScale, const waifu2xCancelFunc cancel_func, const cv::Mat &in, cv::Mat &out);
|
eWaifu2xError ReconstructFloatMat(const bool isReconstructNoise, const bool isReconstructScale, const waifu2xCancelFunc cancel_func, const cv::Mat &in, cv::Mat &out);
|
||||||
eWaifu2xError Reconstruct(const bool isReconstructNoise, const bool isReconstructScale, const waifu2xCancelFunc cancel_func, const cv::Mat &in, cv::Mat &out);
|
eWaifu2xError Reconstruct(const bool isReconstructNoise, const bool isReconstructScale, const waifu2xCancelFunc cancel_func, const cv::Mat &in, cv::Mat &out);
|
||||||
eWaifu2xError AfterReconstructFloatMatProcess(const waifu2xCancelFunc cancel_func, const cv::Mat &floatim, const cv::Mat &in, cv::Mat &out);
|
eWaifu2xError AfterReconstructFloatMatProcess(const bool isReconstructScale, const waifu2xCancelFunc cancel_func, const cv::Mat &floatim, const cv::Mat &in, cv::Mat &out);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Waifu2x();
|
Waifu2x();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user