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

how can I remove noise by using frequency domain technique??

Asked by Long Bunly on 16 Jan 2013

anybody help me how to remove noise from a picture? Consider the image which simulates the effect of mains signal interference in the amplifying electronics of the image sensor? http://imageshack.us/photo/my-images/152/bbbbj.png/

0 Comments

Long Bunly

Products

No products are associated with this question.

2 Answers

Answer by Image Analyst on 16 Jan 2013
Accepted answer

Is this your homework exercise? It sounds like a typical homework problem.

You can easily just fft2() your image, display it and find the spike, then zero out or reduce that spike, and finally inverse transform. If you're taking a class they should have gone over that. It's pretty straightforward.

3 Comments

Long Bunly on 17 Jan 2013

yes that's my homework, it's really hard for me, because i am new with Matlab

Image Analyst on 17 Jan 2013

Here's one of my demos. It doesn't do the whole job for you. You still need to locate the spikes and move the filter to zero them out but it should help.

% Demo macro to filter an image in the Foureir domain.
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.
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;
% Read in demo image.
folder = 'D:\Temporary stuff';
% folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'bbbbj.png';
% 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);
[rows columns numberOfColorBands] = size(grayImage);
if numberOfColorBands > 1
	grayImage = rgb2gray(grayImage);
end
subplot(2,2, 1);
imshow(grayImage, [0 255]);
set(gcf, 'Name', ['Results for ' fullFileName]);
title('Original Image', 'FontSize', fontSize);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % Maximize figure.
grayImage = double(grayImage);
frequencyImage = fftshift(fft2(grayImage));
subplot(2,2, 2);
amplitudeImage = log(abs(frequencyImage));
minValue = min(min(amplitudeImage))
maxValue = max(max(amplitudeImage))
imshow(amplitudeImage, []);
title('Notice the two spikes perpendicular to periodic frequencies', 'FontSize', fontSize);
% zoom(10)
[midpointX, midpointY] = find(amplitudeImage == maxValue)
filterWindowHalfWidth = 1;
for row = midpointY-filterWindowHalfWidth:midpointY+filterWindowHalfWidth
	for column = midpointX-filterWindowHalfWidth:midpointX+filterWindowHalfWidth
		frequencyImage(row-4, column+7) = 0;
		frequencyImage(row+4, column-7) = 0;
	end
end
amplitudeImage2 = log(abs(frequencyImage));
minValue = min(min(amplitudeImage2))
maxValue = max(max(amplitudeImage2))
subplot(2,2, 3);
imshow(amplitudeImage2, [minValue maxValue]);
title('Two dots zeroed out', 'FontSize', fontSize);
% zoom(10)
filteredImage = ifft2(fftshift(frequencyImage));
amplitudeImage3 = abs(filteredImage);
minValue = min(min(amplitudeImage3))
maxValue = max(max(amplitudeImage3))
subplot(2,2, 4);
imshow(amplitudeImage3, [minValue maxValue]);
title('Filtered Image', 'FontSize', fontSize);
% set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % Maximize figure.
% % 
Long Bunly on 17 Jan 2013

Thanks, with your code I have an idea, I should use arithmetic, also teacher require us to use frequency domain technique, I try it again so :), Thank you again.

Image Analyst
Answer by Shashank Prasanna on 16 Jan 2013

What find of filters are you looking for specifically?

Here are some examples of deblurring filters in the image processing toolbox

http://www.mathworks.com/help/images/image-restoration-deblurring.html

3 Comments

Long Bunly on 16 Jan 2013

Thank for you reply, I am not sure what filter I am looking for. but I think I can remove that noise by using frequency domain technique filter, but I don't know how to write a code. you can check that picture's noise by link I uploaded.

Shashank Prasanna on 16 Jan 2013

The link doesn't work. You have to be specific with your question, since its your application you have to know what kind of filtering you want. Here is a link that may help you:

http://www.mathworks.com/help/images/removing-noise-from-images.html

Go through the documentation to see if something is appilcable to you.

Shashank Prasanna

Contact us