图像去噪中的patch size是什么(1篇文章链接和1段代码)
写在前面,因为自己不做图像相关的研究,所以具体内容也不敢妄加总结,自己感觉貌似就是将一整张图分成一块一块的进行处理,每个块之间可以重叠。但具体大家可以看下面的文章链接和代码示例。
文章链接:Patch-based models and algorithms for image denoising: a comparative review between patch-based images denoising methods for additive noise reduction
代码示例:
patch_size, stride = 40, 10
def gen_patches(file_name):
img = cv2.imread(file_name, 0)
h, w = img.shape
scales = [1, 0.9, 0.8, 0.7]
patches = []
for s in scales:
h_scaled, w_scaled = int(h*s),int(w*s)
img_scaled = cv2.resize(img, (h_scaled,w_scaled), interpolation=cv2.INTER_CUBIC)
for i in range(0, h_scaled-patch_size+1, stride):
for j in range(0, w_scaled-patch_size+1, stride):
x = img_scaled[i:i+patch_size, j:j+patch_size]
patches.append(x)
return patches
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)