本文主要是介绍SRCNN的数据处理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
TensorFlow代码
数据处理:
输入为(344,288)的图片,首先进行归一化处理,然后下采样再上采样,得到输入input_,
def preprocess(path, scale=3):
"""
Preprocess single image file
(1) Read original image as YCbCr format (and grayscale as default)
(2) Normalize
(3) Apply image file with bicubic interpolation Args:
path: file path of desired file
input_: image applied bicubic interpolation (low-resolution)
label_: image with original resolution (high-resolution)
"""
image = imread(path, is_grayscale=True)#(344,228)
label_ = modcrop(image, scale)#(342,228)modcrop得到scale的整数倍 # Must be normalized
image = image / 255.
label_ = label_ / 255. input_ = scipy.ndimage.interpolation.zoom(label_, (1./scale), prefilter=False)#(114,76)
input_ = scipy.ndimage.interpolation.zoom(input_, (scale/1.), prefilter=False)#(342,228)
return input_, la
这篇关于SRCNN的数据处理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!