You are on page 1of 4

PERBAIKAN CITRA PADA DOMAIN FREKUENSI

Muhamad Taufik Yusuf


Email: klepitom@yahoo.com

LANGKAH-LANGKAH PERBAIKAN CITRA

Perbaikan citra pada domain frekuensi dilakukan dengan langkah-langkah berikut:

1. Menghitung transformasi fourier dari citra yang akan diperbaiki.

2. Kalikan hasilnya dengan fungsi filter.

3. Invers transformasi untuk mendapat citra yang sudah diperbaiki.

Filter yang digunakan adalah fungsi Gaussian dengan D0 = 20.

TAMPILAN HASIL PROGRAM


LISTING PROGRAM

File Tugas_1.m

function varargout = Tugas_1(varargin)


% TUGAS_1 M-file for Tugas_1.fig
% TUGAS_1, by itself, creates a new TUGAS_1 or raises the existing
% singleton*.
%
% H = TUGAS_1 returns the handle to a new TUGAS_1 or the handle to
% the existing singleton*.
%
% TUGAS_1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TUGAS_1.M with the given input arguments.
%
% TUGAS_1('Property','Value',...) creates a new TUGAS_1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Tugas_1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Tugas_1_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Tugas_1

% Last Modified by GUIDE v2.5 30-Jul-2009 10:58:36

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Tugas_1_OpeningFcn, ...
'gui_OutputFcn', @Tugas_1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before Tugas_1 is made visible.


function Tugas_1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Tugas_1 (see VARARGIN)

% Choose default command line output for Tugas_1


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes Tugas_1 wait for user response (see UIRESUME)


% uiwait(handles.figure1);
clc, clear;

% --- Outputs from this function are returned to the command line.
function varargout = Tugas_1_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure


varargout{1} = handles.output;

% --- Executes on button press in cmdLoadCitra.


function cmdLoadCitra_Callback(hObject, eventdata, handles)
% hObject handle to cmdLoadCitra (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[fileCitra, pathCitra] = uigetfile({'*.bmp; *.jpg; *.png', 'File Citra
(*.bmp,*.jpg, *.png)';
'*.bmp', 'File bitmap (*.bmp)';
'*.jpg', 'File jpeg(*.jpg)';
'*.png', 'File png (*.png)';
'*.*', 'Semua File (*.*)'}, 'buka file Citra');
if ~isequal(fileCitra, 0)
handles.dataCitra = imread(fullfile(pathCitra, fileCitra));
guidata(hObject,handles);
axes(handles.imgCitraAsli);
imshow(handles.dataCitra);
else
return;
end

% --- Executes on button press in cmdEnhanceCitra.


function cmdEnhanceCitra_Callback(hObject, eventdata, handles)
% hObject handle to cmdEnhanceCitra (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%citra = im2double(handles.dataCitra);

citra = handles.dataCitra;
D0 = 20;
[M, N, O] = size(citra);

%transformasi fourier
F = fft2(double(citra));

%range
u = 0:(M - 1);
v = 0:(N - 1);
idx = find(u > M/2);
u(idx) = u(idx) - M;
idy = find(v > N/2);
v(idy) = v(idy) - N;
[V, U] = meshgrid(v,u);

D = sqrt(U.^2 + V.^2);

% fiter lowpass
H = exp(-(D.^2)./(2*(D0^2)));

% fiter highpass
Hp = 1 - H;

%perkalian transformasi dengan filter gaussian


% lowpass
G = F;
for i = 1:O
G(:, :, i) = H.*F(:, :, i);
end

% highpass
Gp = F;
for i = 1:O
Gp(:, :, i) = Hp.*F(:, :, i);
end

%inverse transformasi
g = uint8(real(ifft2(double(G))));
h = uint8(real(ifft2(double(Gp))));

handles.dataCitraLowpass = g;
guidata(hObject,handles);
axes(handles.imgCitraLowpass);
imshow(handles.dataCitraLowpass);

handles.dataCitraHighpass = h;
guidata(hObject,handles);
axes(handles.imgCitraHighpass);
imshow(handles.dataCitraHighpass);

You might also like