Matlab script code for Adaptive median fitering

I need a simple matlab script code for adaptive median filtering with no errors.I have tried many codes but failed to execute a single one.Also I don't know what is a mex file and how to convert the code into a mex file.
The code will have to able to process image of any size and remove the noise associated with it.
Any help will be highly appreciated.
Thank you.

6 Kommentare

piyush kant
piyush kant am 18 Apr. 2013
thanx bro
Image Analyst
Image Analyst am 18 Apr. 2013
Bearbeitet: Image Analyst am 18 Apr. 2013
You're welcome. Please officially mark as "Accepted" to thank me.
haritha c
haritha c am 27 Okt. 2015
can anybody send the same to me?? haritha.c.1991@gmail.com
Image Analyst
Image Analyst am 27 Okt. 2015
I'll attached demo scripts to my Answer below.
reena meshram
reena meshram am 27 Apr. 2016
what is the coding in smf cmf amf value in noisey image
Image Analyst
Image Analyst am 27 Apr. 2016
I have no idea what those acronyms are.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Image Analyst
Image Analyst am 31 Mär. 2013

0 Stimmen

What kind of adaption is being done? I have one that removes salt and pepper noise if you want that. It is just straight MATLAB - no mex files needed.

5 Kommentare

Here's the demo. I have a color version -- if you want that one, let me know.
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
fontSize = 15;
% Read in a standard MATLAB demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'coins.png';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image. numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);
% Display the original image.
subplot(2, 2, 1);
imshow(grayImage);
title('Original Gray Scale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
% Generate a noisy image with salt and pepper noise.
noisyImage = imnoise(grayImage,'salt & pepper', 0.05);
subplot(2, 2, 2);
imshow(noisyImage);
title('Image with Salt and Pepper Noise', 'FontSize', fontSize);
% Median Filter the image:
medianFilteredImage = medfilt2(noisyImage, [3 3]);
% Find the noise. It will have a gray level of either 0 or 255.
noiseImage = (noisyImage == 0 | noisyImage == 255);
% Get rid of the noise by replacing with median.
noiseFreeImage = noisyImage; % Initialize
noiseFreeImage(noiseImage) = medianFilteredImage(noiseImage); % Replace.
% Display the image.
subplot(2, 2, 3);
imshow(noiseFreeImage);
title('Restored Image', 'FontSize', fontSize);
Image Analyst
Image Analyst am 27 Okt. 2015
Attached are two Salt and Pepper removal methods using a median filter to change only the noise pixels and not the "good" pixels.
Ninad Dafale
Ninad Dafale am 17 Jun. 2016
Can you please provide the code for adaptive median filtering for color images?
Image Analyst
Image Analyst am 17 Jun. 2016
That's what the above attached m-file "salt_and_pepper_noise_removal.m" is!
can I get code on same filter but for a random valued noise?

Melden Sie sich an, um zu kommentieren.

Amar
Amar am 31 Mär. 2013

0 Stimmen

ya, That would be good.I just need a working code for adaptive median fitering.

1 Kommentar

Image Analyst
Image Analyst am 31 Mär. 2013
This is not an "answer" to your question, so it should have been a comment to my answer. I'll put my response there.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 29 Mär. 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by