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
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);
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
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);
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)

