Adding Random valued impulse noise to an image
function [ image_noisy ] = addRVIN( image_input, ND, noise_width )
%ADDRVIN adds Random valued impulse noise to an image
% image_input Input noise free image
% ND is noise density that ranges from 0 to 1
% noise_width is width of random valued impulse noise
[~,x] = imhist(image_input);
init_width = x(noise_width);
image_noisy = image_input;
Narr = rand(size(image_noisy));
p = ND/2;
% image_noisy = (image_input + p*rand(size(image_input)))/(1+p);
image_rand = rand(size(image_input));
range_init = init_width;
image_randInit = image_rand*range_init;
% image_noisy(Narr<ND/2) = (init_width + image_rand(Narr<ND/2));
image_noisy(Narr<ND/2) = (image_randInit(Narr<ND/2));
% image_noisy(Narr<ND/2) = (noise_width + p*rand(size(image_input)))/(1+p);
image_randFinal = image_rand*range_init+ x(end) - x(noise_width+1);
image_noisy((Narr>=ND/2)&(Narr<ND)) = image_randFinal((Narr>=ND/2)&(Narr<ND));
% figure, imhist(image_input)
% figure, imhist(image_noisy)
end
引用格式
Sajid Khan (2024). Adding Random valued impulse noise to an image (https://www.mathworks.com/matlabcentral/fileexchange/56324-adding-random-valued-impulse-noise-to-an-image), MATLAB Central File Exchange. 检索来源 .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
- Image Processing and Computer Vision > Image Processing Toolbox > Image Filtering and Enhancement > Image Arithmetic >
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.0.0.0 | Histogram added |