adaptive filter with mask 5*5 for an image with noise

5 次查看(过去 30 天)
how can mplement this adaptive filter with mask 5*5 for an image with noise :
f(x,y) = g(x,y) - ( (ση)^2 / (σL)^2 ) * ( g(x,y)-mL ))
where :
g(x,y) : is the value of the pixel (x,y) in the noisy image
ση : is the variance of the noise corrupting f(x,y)
σL : is the local variance for the pixels in Sxy
mL: the local mean for the pixels in Sxy

采纳的回答

Image Analyst
Image Analyst 2013-7-15
This looks like the Wallis Filter. See http://www.dtic.mil/dtic/tr/fulltext/u2/a248301.pdf. It does a localized contrast stretch where is sets the mean and standard deviation of every window equal to some specified values. There is no built-in MATLAB function to do the Wallis filter. You should be able to do this using stdfilt() and conv2(). Give that a try and come back if you can't figure it out.
  4 个评论
Maria
Maria 2013-7-16
Sxy is the pixels at each location on which the filter window is centerd
The mean gives the average intensity in the region while variance is a measure of contrast
The filter under discussion uses four different values to perform filtering in a certain neighborhood
ση is measured by assumption , all of remaining values can be computed from Sxy
this technique called (adaptive local noise reduction) its a techniques found in gonzales book (image processing) in image restoration cahpter
Image Analyst
Image Analyst 2013-7-16
编辑:Image Analyst 2013-7-16
Do you mean "tired of trying"? Well if you're exhausted of trying different things to program it up, then perhaps this will be enough to kick start your efforts:
% Script to compute the locally adaptive filter:
% f(x,y) = g(x,y) - ( (ση)^2 / (σL)^2 ) * ( g(x,y)-mL ))
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clearvars; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 15;
% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end
% Read in a standard MATLAB gray scale demo image.
button = menu('Use which demo image?', 'CameraMan', 'Moon', 'Eight', 'Coins', 'Pout');
if button == 1
baseFileName = 'cameraman.tif';
elseif button == 2
baseFileName = 'moon.tif';
elseif button == 3
baseFileName = 'eight.tif';
elseif button == 4
baseFileName = 'coins.png';
else
baseFileName = 'pout.tif';
end
% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- 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 in the search path folders.', 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);
if numberOfColorBands > 1
% It's not really gray scale like we expected - it's color.
% Convert it to gray scale by taking only the green channel.
grayImage = grayImage(:, :, 2); % Take green channel.
end
% Display the original gray scale image.
subplot(2, 4, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
% Let's compute and display the histogram.
[pixelCount, grayLevels] = imhist(grayImage);
subplot(2, 4, 5);
bar(pixelCount);
grid on;
title('Histogram of Original Grayscale Image', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
% Get the local mean image
windowSize = 5;
kernel = ones(windowSize)/windowSize^2;
meanImage = conv2(double(grayImage), kernel, 'same');
% Display the local mean image.
subplot(2, 4, 2);
imshow(meanImage, []);
title('Local Mean Image', 'FontSize', fontSize);
% Let's compute and display the histogram.
[pixelCount, grayLevels] = hist(meanImage(:), 100);
subplot(2, 4, 6);
bar(grayLevels, pixelCount);
grid on;
title('Histogram of Local Mean image', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
% Get the standard deviation of the image
nHood = ones(windowSize);
sdImage = stdfilt(grayImage, nHood);
% Display the image.
subplot(2, 4, 3);
imshow(sdImage, []);
title('Standard Deviation Image', 'FontSize', fontSize);
% Let's compute and display the histogram.
[pixelCount, grayLevels] = hist(sdImage(:), 100);
subplot(2, 4, 7);
bar(grayLevels, pixelCount);
grid on;
title('Histogram of Standard Deviation image', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
% Compute the output image
% f(x,y) = g(x,y) - ( (ση)^2 / (σL)^2 ) * ( g(x,y)-mL ))
sn = 4;
sL = 3;
outputImage = double(grayImage) - (sn^2/sL^2) * (double(grayImage) - meanImage);
% Display the image.
subplot(2, 4, 4);
imshow(outputImage, []);
title('Output Image', 'FontSize', fontSize);
% Let's compute and display the histogram.
[pixelCount, grayLevels] = hist(outputImage(:), 100);
subplot(2, 4, 8);
bar(grayLevels, pixelCount);
grid on;
title('Histogram of Output Image', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by