资源简介
这个代码很好大家可以借鉴一下我金额发挥的技术首都机场卡斯深刻的金丝讲授的坚持说四等奖考生的技术快睡觉佛孙大圣是经擦看
代码片段和文件信息
function y = noise(varargin)
% NOISE Adds noise to an image.
%
% NOISE creates a new image by adding noise to the original image.
% NOISE can be used to any matrix (1D 2D 3D nD)
%
% Noisetypes are:
% ‘ag‘ : additive gaussian (default) ‘au‘ : additive uniform
% ‘mg‘ : multiplicative gaussian ‘mu‘ : multiplicative uniform
% ‘sp‘ : salt and pepper
%
% Additive noise sums an random value to the image value at each pixel
% Multiplicative noise replaces a pixel value with an random value
% Salt and Pepper noise replaces a pixel value with the maximum or minimum possible values.
%
% For ‘ag‘ noisetype use: y = NOISE(x‘ag‘ variance [incidence])
% where ‘variance‘ is the variance of the gaussian noise added and the optional parameter
% ‘incidence‘ is the percetual of pixels affected be the noise (default for additive noise=1).
% For a 50% incidence use ‘incidence‘ = .5 and so on.
%
% For ‘au‘ noisetype use : y = NOISE(x‘au‘ maximum [incidence])
% where ‘maximum‘ is the maximum value the uniform noise can achieve
%
% For ‘mg‘ noisetype use : y = NOISE(x‘mg‘ incidence)
% For ‘mu‘ noisetype use : y = NOISE(x‘mu‘ incidence)
% Multiplicative noisetypes require that the ‘incidence‘ parameter. For this kind of noise
% the variance or the maximum (respectivelly for gaussian and uniform noisetypes) are allways
% set to the maximum image value.
%
% For ‘sp‘ noisetype use : y = NOISE(x‘sp‘ incidence)
%
% The ‘maximum‘ and ‘variance‘ parameters can be set as percentual of the maximum - minimum image
% values by using these values as strings containg the percentual rate followed by the percent symbol.
% The ‘incidence‘ can also be expressed as a pecentual in this same way
%
% Example: y = NOISE(x‘ag‘ ‘25%‘)
% y = NOISE(x‘mu‘ 10 .5) -> same as y = NOISE(x‘mu‘10 ‘50%‘)
%
[u noisetype scale incid] = parse_inputs(varargin{:});
if ~isa(u‘double‘)
u = double(u);
end
y = u;
n = zeros(size(u));
if incid ==
评论
共有 条评论