问题描述
我正在尝试对某些图像应用高斯模糊。目前,我正在使用运行良好的 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 (将#修改为@)