Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Image Smoothing not working

Asked by Lalit Patil on 29 Nov 2012

http://www.speedyshare.com/kc85D/x.jpg

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.?

1 Comment

Jan Simon on 29 Nov 2012

Formatted code looks nicer.

Lalit Patil

Products

No products are associated with this question.

1 Answer

Answer by Image Analyst on 29 Nov 2012
Edited by 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);

0 Comments

Image Analyst

Contact us