如何解决在 tensorflow 和 numpy 上使用高斯模糊的不同结果
我正在尝试对某些图像应用高斯模糊。目前,我正在使用运行良好的 tensorflow 2d gaussian filter,但在尝试使用 scipy gaussian filter 后,我注意到尽管使用了相同的参数,但结果却大不相同。
我的代码:
from PIL import Image
import tensorflow as tf
import tensorflow_addons as tfa
from scipy.ndimage.filters import gaussian_filter
def apply_blur_tensor(img,sigma_x=3.5,sigma_y=4.6):
img_temp = np.asarray(img).astype(float)
img_temp = tf.convert_to_tensor(img_temp)
img_temp = tfa.image.gaussian_filter2d(image=img_temp,sigma=(sigma_x,sigma_y),padding='REFLECT')
img_temp = img_temp.numpy()
return Image.fromarray(img_temp.astype('uint8'))
def apply_blur_numpy(img,sigma_y=4.6):
img_temp = np.asarray(img).astype(float)
img_temp = gaussian_filter(img_temp,mode='reflect')
return Image.fromarray(img_temp.astype('uint8'))
我想我在 tensorflow 实现上做错了什么,谁能告诉我是什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。