如何使用Python在图像上添加具有真实高斯形状的高斯模糊

假设我有以下2D阵列图像:

img = np.array([
           [0,1,0.5,0],[0,0]])

我想对其施加高斯模糊,以便图像如下:

imgBlurred = np.array([
           [0.0,0.2,0.7,0.3,0.4,0.1],[0.0,0.1]])

基本上,我希望得到这样的结果:在原始图像中,高斯的1值非常粗,而0.5值则高。

直到现在,我将按照以下步骤操作:

 from scipy import ndimage
 import numpy as np
 #img is a numpy array
 imgBlurred = ndimage.filters.gaussian_filter(img,sigma=0.7)
 #Normalisation by maximal value,because the gaussian blur reduce the 1 to ~0.5
 imgBlurred = imgBlurred/imgBlurred.max()
 imgBlurred[imgBlurred > 1] = 1# In case of the maximal value was > 1

但是,这样做的话,对于模糊图像上的1和0.5来说,应该更大。 如果有人知道如何解决此“问题”,我想提出一些建议!

plmoknnm 回答:如何使用Python在图像上添加具有真实高斯形状的高斯模糊

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2971152.html

大家都在问