def DefocusBlur(img, dim):
imgarray = np.array(img, dtype="float32")
kernel = DiskKernel(dim)
convolved = convolve2d(imgarray, kernel, mode='same', fillvalue=255.0).astype("uint8")
img = Image.fromarray(convolved)
return img
评论列表
文章目录