Skip to content

Quenstions of testing phase #5

@Zheng222

Description

@Zheng222

Hello, I carefully read your test code and find that you use opencv to read image.

SESR/test.py

Lines 63 to 65 in e43f85b

for pimg in pimages:
img=cv2.imread(path+'/'+pimg)
psnr,ssim=predict(img,save,convert,eva,pimg)

Actually, the img is in BGR mode. So the following operations are wrong.

SESR/test.py

Lines 86 to 89 in e43f85b

h,w,_=img_read.shape
im_gt_y=convert_rgb_to_y(img_read)
gt_yuv=convert_rgb_to_ycbcr(img_read)
im_gt_y=im_gt_y.astype("float32")

In addition, the customized convert_rgb_to_y() and convert_rgb_to_ycbcr() functions are different from these in Matlab. I find skimage.color.rgb2ycbcr() is same as that in Matlab.

SESR/test.py

Lines 154 to 162 in e43f85b

def PSNR(pred, gt, shave_border=0):
height, width = pred.shape[:2]
pred = pred[shave_border:height - shave_border, shave_border:width - shave_border]
gt = gt[shave_border:height - shave_border, shave_border:width - shave_border]
imdff = pred - gt
rmse = math.sqrt(np.mean(imdff ** 2))
if rmse == 0:
return 100
return 20 * math.log10(255.0 / rmse)

The inputs of this PSNR function (pred, gt) are float type, but the traditional inputs in Matlab are uint8 type, and I find that using your PSNR function can compute higher psnr index. I obtain the rgb images by using the test code and then test these in Matlab R2017a and get the results as follows.

              PSNR          SSIM
tested
Set5         31.99         0.891

original
Set5         32.11         0.895

@opteroncx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions