how i can implement these algorithm in matlab
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Adaptive median filter changes size of Sxy (the size of the neighborhood) during operation.
- Notation
Zmin = minimum gray level value in Sxy
Zmax = maximum gray level value in Sxy
Zmed = median of gray levels in Sxy
Zxy = gray level at coordinates (x, y)
Smax = maximum allowed size of Sxy
- Algorithm
Level A: A1 = Zmed - Zmin
A2 = Zmed - Zmax
if A1 > 0 AND A2 < 0, go to level B
else increase the window size
if window size < Smax, repeat level A
else output Zxy
Level B: B1 = Zxy - Zmin
B2 = Zxy - Zmax
if B1 > 0 AND B2 < 0, output Zxy
else output Zmed
採用された回答
Image Analyst
2017 年 10 月 13 日
編集済み: Image Analyst
2017 年 10 月 13 日
I use an adaptive median filter to do salt and pepper removal. You can easily adapt it to change the values from 0 and 255 to Zmin and Zmax. Let me know how it goes. Attach your adapted code if you run into problems.
9 件のコメント
aliah aljohani
2017 年 10 月 13 日
thank you but these code for median filter i need one for adaptive filter i have code but not works
can you see
Image Analyst
2017 年 10 月 13 日
編集済み: Image Analyst
2017 年 10 月 13 日
Oh, you didn't say that at first. But unfortunately, you forgot to attach your m-file and 'shyamgs.bmp'. I'll wait until then, since I can't fix your code unless I have your code.
Also explain what this extra edge processing does. How does that make the image better than a regular modified median filter?
Can you ask the author to add more comments? Like explain why there are weird lines in there like this:
ip_edge(i,j) = ip_edge(i,j);
aliah aljohani
2017 年 10 月 13 日
how i can change the values from 0 and 255 to Zmin and Zmax.
in your cod
i am sorry I do not know how i can do these
Image Analyst
2017 年 10 月 13 日
編集済み: Image Analyst
2017 年 10 月 13 日
Replace this line
% Find the noise. It will have a gray level of either 0 or 255.
noiseImage = (noisyImage == 0 | noisyImage == 255);
with this line:
% Find the noise. It will have a gray level of either less than Zmin or more than Zmax.
noiseImage = (noisyImage <= Zmin | noisyImage >= Zmax);
Again, attach your image and m-file.
Image Analyst
2017 年 10 月 13 日
編集済み: Image Analyst
2017 年 10 月 13 日
Exactly what does "code but not works" mean? And I mean EXACTLY.
aliah aljohani
2017 年 10 月 13 日
編集済み: aliah aljohani
2017 年 10 月 13 日
i mean these code not work it has some error at for ,if and end and i do not know how i can fixed these error
Image Analyst
2017 年 10 月 14 日
This gets rid of the error, so that now you can continue to figure out why your code doesn't get rid of salt and pepper noise like my code does.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
grayImage = imread('h1.jpg');
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage)
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
% grayImage = rgb2gray(grayImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
grayImage = grayImage(:, :, 2); % Take green channel.
end
subplot(2,2,1);
imshow(grayImage)
title('Original image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
drawnow;
% Add noise.
noiseFreeImage = imnoise(grayImage,'salt & pepper',.02);
subplot(2,2,2);
imshow(noiseFreeImage);
title('noisy image', 'FontSize', fontSize);
drawnow;
% Make failed attempt to denoise the image.
Smax = 9;
for col = 1:columns-2
for row = 1:rows-2
n = noiseFreeImage(row:row+2,col:col+2);
Zmin = min(n(:));
Zmax = max(n(:));
Zmed = median(n(:));
sx = 3;
sy = 3;
A1 = Zmed-Zmin;
A2 = Zmed-Zmax;
if (A1>0) && (A2<0)
B1 = Zxy-Zmin;
B2 = Zxy-Zmax;
if (B1>0) && (B2<0)
noiseFreeImage(row:row+2,col:col+2) = n(row, col);
break;
else
noiseFreeImage(row:row+2,col:col+2) = Zmed;
break;
end
else
sx = sx+2;
sy = sy+2;
if (sx > Smax) && (sy > Smax)
noiseFreeImage(row:row+2,col:col+2) = n(row, col);
end
end
end
end
subplot(2,2,3);
imshow(noiseFreeImage)
title('Denoised image', 'FontSize', fontSize);
aliah aljohani
2017 年 10 月 14 日
Yes No errors found in the code Thank you very much for helping me
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Filtering についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

