yulunzhang/RCAN

About the calculation of PSNR

BEAUTIFULSB opened this issue · 0 comments

diff = (sr - hr).data.div(rgb_range)
shave = scale
if diff.size(1) > 1:
convert = diff.new(1, 3, 1, 1)
convert[0, 0, 0, 0] = 65.738
convert[0, 1, 0, 0] = 129.057
convert[0, 2, 0, 0] = 25.064
diff.mul_(convert).(256)
diff = diff.sum(dim=1, keepdim=True)
'''
if benchmark:
shave = scale
if diff.size(1) > 1:
convert = diff.new(1, 3, 1, 1)
convert[0, 0, 0, 0] = 65.738
convert[0, 1, 0, 0] = 129.057
convert[0, 2, 0, 0] = 25.064
diff.mul
(convert).div_(256)
diff = diff.sum(dim=1, keepdim=True)
else:
shave = scale + 6
'''
valid = diff[:, :, shave:-shave, shave:-shave]
mse = valid.pow(2).mean()

请问为什么要乘以convert,它的作用是什么,valid = diff[:, :, shave:-shave, shave:-shave] 的含义是什么呀?感谢回答!