MaokeAI / SRCNN-keras

94 stars 51 forks source link

both bicubic and srcnn 's PSNR is lower than your result #8

Open ninesun127 opened 6 years ago

ninesun127 commented 6 years ago

hello. i have already ran this code,and the result shows that srcnn is reall perform better than bicubic. although srcnn's psnr is higher than bicubic.

my result shows that the psnr is lower than yours and the article, i can not understand.

Y-channel,range[-6,6],can you give me your advice?

ninesun127 commented 6 years ago

import cv2 import numpy import math

def psnr(target, ref): target_data = numpy.array(target, dtype=float) ref_data = numpy.array(ref, dtype=float) diff = ref_data - target_data diff = diff.flatten('C')

rmse = math.sqrt(numpy.mean(diff ** 2.))
print rmse
return 20. * math.log10(255. / rmse)

IMG_NAME = "Set5/baby_GT.bmp"

img = cv2.imread(IMG_NAME, cv2.IMREAD_COLOR) img = cv2.cvtColor(img, cv2.COLOR_BGR2YCrCb) Y_img = cv2.resize(img[:, :, 0], (img.shape[1] / 2, img.shape[0] / 2), cv2.INTER_CUBIC) Y_img = cv2.resize(Y_img, (img.shape[1], img.shape[0]), cv2.INTER_CUBIC) img[:, :, 0] = Y_img

im1 = cv2.imread(IMG_NAME, cv2.IMREAD_COLOR) im1 = cv2.cvtColor(im1, cv2.COLOR_BGR2YCrCb)[6:-6, 6:-6, 0]

im2 = img[6:-6, 6:-6, 0] print "bicubic:"

print psnr(im1, im2)

psnr:34. 39 while yours is 37