How can I create a noise reduction code?
古いコメントを表示
I studying in this code but it doesn't run. We can see only original picture. How can we fixed it?
f=imread('C:\Users\MFT\Desktop\tst.gif');
imshow(f),title('original image');
g =imnoise(f,'gaussian',0,0.1);
figure,imshow(g),title('noisy image')
h = fspecial('unsharp');
j =imfilter(g,h);
figure,imshow(j),title(' linear filtered image')
k = filter2(fspecial('average',3),g)/255;
figure,imshow(k),title('FIR filtered image')
l = medfilt2(g,[3 3]);
figure,imshow(l),title(' median filtered image')
m = wiener2(g,[5 5]);
figure, imshow(m),title('adaptive filtered image')
回答 (1 件)
Prateek Rai
2021 年 10 月 12 日
To my understanding, you have created a noise reduction code but cannot see the output image.
The error is probably coming in line 8 of your code i.e.
k = filter2(fspecial('average',3),g)/255;
It is because this filter is in return using conv2 on RGB image which is not supported. Hence, you need to convert the RGB image to gray then perform the operations.
The code would look like:
f = imread("peppers.png");
f = rgb2gray(f); %% converting to grayscale
imshow(f),title('original image');
g =imnoise(f,'gaussian',0,0.1);
figure,imshow(g),title('noisy image')
h = fspecial('unsharp');
j =imfilter(g,h);
figure,imshow(j),title(' linear filtered image')
k = filter2(fspecial('average',3),g)/255;
figure,imshow(k),title('FIR filtered image')
l = medfilt2(g,[3 3]);
figure,imshow(l),title(' median filtered image')
m = wiener2(g,[5 5]);
figure, imshow(m),title('adaptive filtered image')
You can refer to rgb2gray MathWorks Documentation page to learn more on converting RGB image or colormap to grayscale.
カテゴリ
ヘルプ センター および File Exchange で Image Category Classification についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!