Sharpening

No Comments
Operasi penajaman citra bertujuan memperjelas tepi pada objek di dalam citra. Penajaman citra merupakan kebalikan dan operasi pelembutan citra, karena operasi ini menghilangkan bagian citra yang lembut.
Operasi penajaman dilakukan dengan melewatkan citra pada penapis lolos-tinggi (highpass filter). Penapis lolos-tinggi akan meloloskan (atau memperkuat) komponen yang berfrekuensi tinggi (misalnya tepi atau pinggiran objek) dan akan menurunkan komponen berfrekuensi rendah. Akibatnya, pinggiran objek telihat lebih tajam dibandingkan sekitarnya.
Selain untuk mempertajam gambar, penapis lolos-tinggi juga digunakan untuk mendeteksi keberadaan tepi (edge detection). Dalam hal ini, pixel-pixel tepi ditampilkan lebih terang (highlight) sedangkan pixel-pixel bukan tepi dibuat gelap (hitam).
 Aturan penapis lolos-tinggi :
  • koefisien penapis boleh positif, negatif, atau nol
  •  jumlah semua koefisien adalah 0 atau 1

Jika jumlah koefisien = 0, maka komponen berfrekuensi rendah akan turun nilainya, sedangkan jika jumlah koefisien, sama dengan 1, maka komponen berfrekuensi rendah akan tetap sama dengan nilai semula.
Listing Program :
function varargout = sharpening(varargin)% SHARPENING MATLAB code for sharpening.fig%      SHARPENING, by itself, creates a new SHARPENING or raises the existing%      singleton*.%%      H = SHARPENING returns the handle to a new SHARPENING or the handle to%      the existing singleton*.%%      SHARPENING('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in SHARPENING.M with the given input arguments.%%      SHARPENING('Property','Value',...) creates a new SHARPENING or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before sharpening_OpeningFcn gets called.  An%      unrecognized property name or invalid value makes property application%      stop.  All inputs are passed to sharpening_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 sharpening
% Last Modified by GUIDE v2.5 30-Oct-2012 08:58:40
% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @sharpening_OpeningFcn, ...                   'gui_OutputFcn',  @sharpening_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 sharpening is made visible.function sharpening_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 sharpening (see VARARGIN)
% Choose default command line output for sharpeninghandles.output = hObject;
% Update handles structureguidata(hObject, handles);
% UIWAIT makes sharpening wait for user response (see UIRESUME)% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.function varargout = sharpening_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 structurevarargout{1} = handles.output;

% --- Executes on button press in Browse.function Browse_Callback(hObject, eventdata, handles)% hObject    handle to Browse (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)proyek=guidata(gcbo);[namafile,direktori]=uigetfile({'*.jpg';'*.bmp';'*.png';'*.tif'},'Buka Gambar')if isequal(namafile,0)return;endeval(['cd ''' direktori ''';']);I=imread(namafile);set(proyek.figure1,'CurrentAxes',proyek.axes1);set(imshow(I));set(proyek.figure1,'Userdata',I);set(proyek.axes1,'Userdata',I);

% --- Executes on button press in Sharp.function Sharp_Callback(hObject, eventdata, handles)% hObject    handle to Sharp (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)proyek=guidata(gcbo);I=get(proyek.axes1,'Userdata');if isequal(I,[])msgbox('Belum ada gambar!','Peringatan','warn');elsePSF=fspecial('unsharp');A=imfilter(I,PSF,'replicate');set(proyek.figure1,'CurrentAxes',proyek.axes2);set(imshow(A));set(proyek.axes2,'Userdata',A);redo_Callback(hObject, eventdata, handles);end

% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton4 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)proyek=guidata(gcbo);set(proyek.figure1,'CurrentAxes',proyek.axes1);cla;set(proyek.figure1,'CurrentAxes',proyek.axes2);cla;

% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton5 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)proyek=guidata(gcbo);[namafile,direktori]=uiputfile({'*.jpg';'*.*'},'Simpan Citra');I=get(proyek.axes2,'Userdata');imwrite(I,strcat(direktori,namafile));

Komponen digunakan adalah axes, button, dan text.

Tampilan Program Sharpening dengan Matlab
Tampilan awal program

Tampilan saat mem-browse gambar

Tampilan saat gambar telah dipilih

Tampilan setelah terjadi sharpening (gambar kanan)

Bagi yang mau mendownload program sharpening ini silahkan download di link ini http://www.mediafire.com/?oqp5lcp1aqh5k61

Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment