Adding noise to image and removing it with average filter
Show older comments
.
guide me please?
im = imread('flower.tif');
noiseIm = imnoise(im, 'gaussian', 0.1); % adding the sine waves to the noise to image
subplot(2,3,1),imshow(noiseIm);
xlabel('Gaussian');
en = 127 ;
[x,y]=meshgrid(1:256,1:256 );
s=1+sin(x+y/1.5 );
grayImage = im ;
imshow(grayImage , [9 9])
ep=(double(en)/128+s)/4;
x = filter2(fspecial('average',3), noiseIm)/255; %removing nosie by the average filter method
subplot(2,3,2),
imshow(x);
label('Average Filter');
denoise2 = wiener2(noiseIm, []); %removing nosie by the wiener filter method
subplot(2,3,3), imshow(denoise2);
xlabel('Wiener Filter');
Im getting the following errors and im not sure what I should do to fix
it. anything ideas?
(Error using images.internal.checkDisplayRange (line 19)
HIGH must be greater than LOW.
Error in images.internal.imageDisplayValidateParams (line 58)
common_args.DisplayRange = images.internal.checkDisplayRange(common_args.DisplayRange,mfilename);
Error in images.internal.imageDisplayParseInputs (line 79)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in imageprocessing (line 11)
imshow(grayImage , [9 9]))
Answers (1)
The line mentioned in the error is certainly nonsensical, but afaik it shouldn't actually throw an error (at least in R2009b - R2019b). Specifying a display range vector where both elements are equal has no purpose. I can't find where exactly in the input parsing it discards the parameter, but [9 9] is simply ignored, and the display uses the default [0 255] range.
Other changes are noted:
im = imread('cameraman.tif'); % i don't have that image, so i'm just using this
noiseIm = imnoise(im, 'gaussian', 0.1); % adding the sine waves to the noise to image
subplot(2,3,1), imshow(noiseIm);
xlabel('Gaussian');
en = 127 ;
[x,y] = meshgrid(1:256,1:256 );
s = 1+sin(x+y/1.5 );
grayImage = im;
imshow(grayImage) % use a valid range, or don't specify one
ep = (double(en)/128+s)/4;
x = filter2(fspecial('average',3), noiseIm)/255; %removing nosie by the average filter method
subplot(2,3,2),
imshow(x);
xlabel('Average Filter'); % typo
denoise2 = wiener2(noiseIm); % specifying the filter size with an empty vector is invalid syntax
subplot(2,3,3), imshow(denoise2);
xlabel('Wiener Filter');
Also note that the first subplot gets overwritten
1 Comment
Amad Kadir
on 17 Oct 2021
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!