Skip to content

Latest commit

 

History

History
39 lines (24 loc) · 2.46 KB

README.md

File metadata and controls

39 lines (24 loc) · 2.46 KB

PSNR_metric

Calculating PSNR is a very important task in super-resolution research because PSNR is one of the most commonly used metrics. But early researchs were all on matlab, also including the code to calculate PSNR and preprocess(bicubic downsample and upsample). As most of the current mainstream deep learning frameworks are based of python, I need to re-write the calculating PSNR and preprocess code in python.

Thanks to the work in https://github.com/fatheral/matlab_imresize, it successfully reproduces the function imresize() in Matlab. This code is used to downsample and upsample the picture. And I found out that, the reproduction code is very successful when dealing with double type, but there are some problems when dealing with uint8 type(I only test the part of bicubic). The reason is still unknown yet.

My code for calculating PSNR is based on the code of matlab version in http://mmlab.ie.cuhk.edu.hk/projects/SRCNN.html.

Later I will draw a flowchart about calculating PSNR and put it on github.

How to use

Set5 has been prepared for test.

Briefly, you need to use the picture generate by the code in ./matlab_code and ./matlab_imresize-master, and put them into ./PSNR to calculate PSNR. You can read the readme.md in each code filter, which I write down how to use the code in detail.

Result

Method Language PSNR
test without saving Matlab 33.6614
save the double bicubic image and test Matlab 33.6529
save the uint8 bicubic image and test Matlab 33.6396
save the double bicubic image and test python 33.6529
save the uint8 bicubic image and test python 33.6404
use PIL to resize python 33.6088
use Opencv to resize python 30.9556

Method 1 calculates PSNR without saving the pictures, while method 2 and 3 generate the pictures and then read the pictures to calculate PSNR.

Method 4 and 5 use the imresize() in https://github.com/fatheral/matlab_imresize.

Method 6 and 7 are an simple attempt to resize image with existing libraries, and get unsatisfied result.

I have tested the PSNR calculated by the pictures generated by Method 2 and 3 in both python and Matlab, and get the same result. So the code of calculating PSNR in python version is quite the same as the Matlab version.

Flowchart

Coming soon...