Image Smoothing not working

4 views (last 30 days)
Lalit Patil
Lalit Patil on 29 Nov 2012
I have this image..
To detect it as a circle i tried smoothing on it,and tried to remove extra noise but it isn't working..
I = imread('x.jpg');
I = I(:,:,3);
myfilter = fspecial('gaussian',[3 3], 0.5);
myfilteredimage = imfilter(I, myfilter, 'replicate');
imshow(myfilteredimage)
and, i got the same result..
.......................................................................
So, which new method can be applied.?

Answers (1)

Image Analyst
Image Analyst on 29 Nov 2012
Edited: Image Analyst on 29 Nov 2012
Your filter is so tiny and narrow that it's essentially almost a delta function. So you won't see a very noticeable effect. Try making the window larger than 3 by 3 and the spread of the Gaussian more than half a pixel. See this demo:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
grayImage = imread('circles.png');
[rows columns numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
grayImage = rgb2gray(grayImage);
end
% Display the original gray scale image.
subplot(2, 3, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% 3x3 filter
filterWidth = 3;
gaussianSpread = 0.5;
myfilter = fspecial('gaussian', [filterWidth filterWidth], gaussianSpread);
% Display the original gray scale image.
subplot(2, 3, 2);
imshow(myfilter, []);
title('The Filter Kernel', 'FontSize', fontSize);
myfilteredimage = imfilter(grayImage, myfilter, 'replicate');
% Display the original gray scale image.
subplot(2, 3, 3);
imshow(myfilteredimage, []);
title('Filtered Grayscale Image', 'FontSize', fontSize);
% 13x13 filter
filterWidth = 13;
gaussianSpread = 5;
myfilter2 = fspecial('gaussian', [filterWidth filterWidth], gaussianSpread);
% Display the original gray scale image.
subplot(2, 3, 5);
imshow(myfilter2, []);
title('The Filter Kernel', 'FontSize', fontSize);
myfilteredimage2 = imfilter(grayImage, myfilter2, 'replicate');
% Display the original gray scale image.
subplot(2, 3, 6);
imshow(myfilteredimage2, []);
title('Filtered Grayscale Image', 'FontSize', fontSize);

Community Treasure Hunt

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

Start Hunting!