DNN SUPERRES outputs blurry images

I want to add super resolution support in my application. Ideally upscale images to 2 times or even 4 times the initial resolution. My implementation is based on this tutorial. Unfortunately dnn superres outputs blurry images.

Here the test pictures:

  • native_image.jpg → The original image. Image resolution is 800x800

  • super_resolution_test.jpg → The input of super resolution. Image resolution is 400x400

  • super_resolution_test_upscaled_x4.jpg → The output of dnn superres using EDSR. Image resolution is 1600x1600

  • torch-srgan_upscaled_x4.jpg → The output of Torch Srgan. Image resolution is 1600x1600

You can see that super_resolution_test_upscaled_x4.jpg is blurry.

You can clearly see it by placing super_resolution_test_upscaled_x4.jpg and torch-srgan_upscaled_x4.jpg in same folder. Open one and cycle between them.

The blurriness is particularly visible on the light bulbs.

Here my code sample based on the tutorial. I use the EDSR_x4.pb model from EDSR_Tensorflow github.

using namespace cv;
using namespace dnn;
using namespace dnn_superres;

Mat upscaleImage(Mat img, std::string modelName, std::string modelPath, int scale) {
	DnnSuperResImpl sr;
	sr.readModel(modelPath);
	sr.setModel(modelName, scale);
	// Output image
	Mat outputImage;
	sr.upsample(img, outputImage);
	return outputImage;
}

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow)
{
	try
	{
		Mat img = imread("D:\\super_resolution_test.jpg");

		std::string path = "D:\\ResizingModels\\EDSR_Tensorflow-master\\models\\EDSR_x4.pb";
		std::string modelName = "edsr";
		int scale = 4;

		Mat result = upscaleImage(img, modelName, path, scale);

		cv::imwrite("D:\\super_resolution_test_upscaled_x4.jpg", result);
	}
	catch (cv::Exception& ex)
	{
		Debug_Trace("What happened: " << ex.what());
	}

	return 0;
}

I tried other algorithms: ESPNC, FSRCNN and LapSRN. they all ouputs blurry images.

Please am I doing something wrong?

Thank you :slight_smile:

References:
torch-srgan : Super Resolution

EDSR_Tensorflow github models : EDSR_Tensorflow/models at master · Saafke/EDSR_Tensorflow · GitHub

i dont think, there’s anything wrong with your code, however,
if you try to make qualitative assessments, do not use lossy jpeg for in/output (png or such),