我试图搜索与 Matlab 函数(imnoise)相对应的 python 函数。我想使用高斯白噪声来增强图像。高斯白噪声的 matlab 代码:[I, map]=imread("img.png");I=double(I)/255;V=var(I(:)); %compute the image varianceJ=imnoise(I, 'gaussian', 0, V/10); %insert gaussian white noise with mean zero and tenth of that variance
1 回答

泛舟湖上清波郎朗
TA贡献1818条经验 获得超3个赞
你可以使用 numpy 和 Pillow !
from PIL import Image
import numpy as np
# Load the image into a numpy array
I = Image.open(filename)
I_array = np.array(im)
# Calculate the variance for the image and the noise
M = 0
V = np.var(im_array)
noise = np.random.normal(mean, variance, I_array.shape)
# Add the noise to the image numpy array and convert
# everything back to a PIL image.
I_array_noise = np.add(I_array, noise)
J = Image.fromarray(I_array_noise)
添加回答
举报
0/150
提交
取消