本文介绍了如何为图像添加5%的高斯噪声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们定义:

百分比噪声数字表示白高斯噪声的标准偏差与整个图像的信号的百分比。

假设我有脑图像,我想通过Matlab将 5%高斯噪声添加到整个图像(组织)代码:

Assume I have a brain image, I want to add 5% Gaussian noise to whole image (tissues) by Matlab code:

I=imread('brain91.png'); I=rgb2gray(I);I=double(I);
I = I - min(I(:));
I = I / max(I(:));

%// Add noise to image
v = 0.05*var(I(:));
I_noisy = imnoise(I, 'gaussian', 0, v);
I_noisy=255.*I_noisy;
subplot(121);imshow(I,[]);subplot(122);imshow(I_noisy,[])

该图显示原始图像(左侧)和右侧的噪声图像。你认为我的实现对于上面的定义是否正确? - (按设定值约为5%高斯噪声v = 0.05 * var(I(:)))

The figure show original image (left side) and noise image in right side. Do you think that my implementation is correct for above definition? - (about 5% Gaussian noise by set v = 0.05*var(I(:)))

推荐答案

Ander Biguri和dasdingonesin都有正确的断言。您的代码肯定会正确地将高斯噪声添加到图像中,但请确保通过在 var 0.05 来计算实际差异c $ c>计算。

Both Ander Biguri and dasdingonesin have correct assertions. Your code is certainly adding Gaussian noise to the image properly, but make sure you account for the actual variance by squaring the 0.05 in your var calculation.

或者,您可以使用而不是 var 并对整个计算进行平方以得到相同的结果:

Alternatively, you can use std instead of var and square the entire calculation to get the same thing:

I=imread('brain91.png'); I=rgb2gray(I);I=double(I);
I = I - min(I(:));
I = I / max(I(:));

%// Add noise to image
%v = (0.05^2)*var(I(:)); %// Option #1
v = (0.05*std(I(:)))^2; %// Option #2
I_noisy = imnoise(I, 'gaussian', 0, v);
I_noisy=255.*I_noisy;
subplot(121);imshow(I,[]);subplot(122);imshow(I_noisy,[])

这篇关于如何为图像添加5%的高斯噪声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 10:00