我試圖搜索與 Matlab 函數(shù)(imnoise)相對(duì)應(yīng)的 python 函數(shù)。我想使用高斯白噪聲來(lái)增強(qiáng)圖像。高斯白噪聲的 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貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超3個(gè)贊
你可以使用 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)
添加回答
舉報(bào)
0/150
提交
取消