Dutormasi.com – Operator laplacian adalah titik titk tepi yang cara menemukan titik perpotongannya dengan sumbu x ileh turunan kedua -> sehingga sering disebut dengan zero crossing operaror b.

Kemudian operator laplacian sangat sensitif terhadap noise yang terletak pada titik titik tepi -> dapat diatasi dengan laplacian of gaussian yang merupakan kombinasi dari operartor laplaciaon dengan operator gaussian.

Source Code :

  1. Laplacian.m

function J = laplacian(I, Thres)
Mask = [0 1 0;
1 -4 1;
0 1 0];
Tepi = convolve(I, Mask)
J = thresholding(Tepi, Thres);
function B = convolve(A, k)
[r c] = size(A);
[m n] = size(k);
h = rot90(k, 2);
center = floor((size(h)+1)/2);
left = center(2) – 1;
right = n – center(2);
top = center(1) – 1;
bottom = m – center(1);
Rep = zeros(r + top + bottom, c + left + right);
for x = 1 + top : r + top
for y = 1 + left : c + left
Rep(x,y) = A(x – top, y – left);
end
end
B = zeros(r , c);
for x = 1 : r
for y = 1 : c
for i = 1 : m
for j = 1 : n
q = x – 1;
w = y -1;
B(x, y) = B(x, y) + (Rep(i + q, j + w) * h(i, j));
end
end
end
end
function Hasil = thresholding(Array, T)
row = size(Array, 1);
col = size(Array, 2);
Hasil = zeros(row, col);
for x = 1 : row
for y = 1 : col
if Array(x, y) >= T
Hasil(x, y) = 1;
else
Hasil(x, y) = 0;
end
end
end

Source code diatas disimpan dengan nama m-file “laplacian.m”. Kemduain selanjutnya bisa diuji keberhasilannya dengan memasukan souce code dibawah ini. Buatlah suatu m-file dan tuliskan source code dibawah ini :

clear; clc;
I = [4 4 4 8 8 8 8;
4 4 4 8 8 8 8;
4 4 4 8 8 8 8;
4 4 4 8 8 8 8;
4 4 4 8 8 8 8];
Hsl = laplacian(I, 1.0)

Hasil dari soruce code diatas berturut turut hasil konvolusi matriks citra dengan mask dan hasil akhir setelah dilakukan thrsholing adalah sebagai berikut :

Cara Melakukan Operator Laplacian Of Gaussian

Nahhhh. Untuk coba perintah untuk melakukan edge detection pada citra camereman.tif adalah sebagai berikut. berikut source code nya :

clear; clc;
I = imread(‘cameraman.tif’);
Hsl = laplacian(im2double(I), 0.25);
imshow(I);
figure, imshow(im2uint8(Hsl));

Maka akan deteksi sisi yang dilakukan operator laplacian menghasilkan tepi yang lebih akurat dibandingkan operator gradien mesikupun dengan nilai threshol luminance yang sama :

Cara Melakukan Operator Laplacian Of Gaussian
Cara Melakukan Operator Laplacian Of Gaussian
Cara Melakukan Operator Laplacian Of Gaussian

Deteksi Tepi Menggunakan Operator Prewitt, Sobel, Roberts, Canny, dan LOG

Baca Juga :  Cara Melakukan Pengolahan Citra Dasar Pada Matlab | 2

Source Code :

function varargout = openbtn1(varargin)
% OPENBTN1 M-file for openbtn1.fig
% OPENBTN1, by itself, creates a new OPENBTN1 or raises the existing
% singleton. % % H = OPENBTN1 returns the handle to a new OPENBTN1 or the handle to % the existing singleton.
%
% OPENBTN1(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in OPENBTN1.M with the given input arguments.
%
% OPENBTN1(‘Property’,’Value’,…) creates a new OPENBTN1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before openbtn1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to openbtn1_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 openbtn1

% Last Modified by GUIDE v2.5 01-Jan-2020 10:54:43

% Begin initialization code – DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @openbtn1_OpeningFcn, …
‘gui_OutputFcn’, @openbtn1_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 openbtn1 is made visible.
function openbtn1_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 openbtn1 (see VARARGIN)

Baca Juga :  Cara Pendeteksian Tepi Operator Gradien Pertama, Operator Robert, Operator Prewit, dan Operator Sobel Matlab

% Choose default command line output for openbtn1
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes openbtn1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% — Outputs from this function are returned to the command line.
function varargout = openbtn1_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 Open.
% Code tombol Open —-
function Open_Callback(hObject, eventdata, handles)
open=guidata(gcbo);
[namafile,direktori]=uigetfile({‘.jpg;.bmp;*.tif’},’OpenImage’);
I=imread(namafile);
set(open.figure1,’CurrentAxes’,open.axes1);
set(imagesc(I));colormap(‘gray’);
set(open.axes1,’Userdata’,I);
% hObject handle to Open (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% — Executes on button press in pushbutton2.
% Code Tombol operator Prewitt
function pushbutton2_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I=get(proyek.axes1,’Userdata’);
gray=rgb2gray(I);
BW=edge(gray,’prewitt’);
set(proyek.figure1,’CurrentAxes’,proyek.axes2);
set(imshow(BW));
set(proyek.axes2,’Userdata’,I);
redo_Callback(hObject,eventdata, handles);
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% — Executes on button press in pushbutton3.
% Code Tombol operator Robert
function pushbutton3_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I=get(proyek.axes1,’Userdata’);
gray=rgb2gray(I);
BW=edge(gray,’roberts’);
set(proyek.figure1,’CurrentAxes’,proyek.axes2);
set(imshow(BW));
set(proyek.axes2,’Userdata’,A);
redo_Callback(hObject,eventdata, handles);
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% — Executes on button press in pushbutton4.
% Code Tombol operator Canny
function pushbutton4_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I=get(proyek.axes1,’Userdata’);
gray=rgb2gray(I);
BW=edge(gray,’canny’);
set(proyek.figure1,’CurrentAxes’,proyek.axes2);
set(imshow(BW));
set(proyek.axes2,’Userdata’,A);
redo_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)

Baca Juga :  Konvolusi Pada Citra Pengolahan Citra Digital Lengkap

% — Executes on button press in pushbutton5.
% Code Tombol operator Sobel
function pushbutton5_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I=get(proyek.axes1,’Userdata’);
gray=rgb2gray(I);
BW=edge(gray,’sobel’);
set(proyek.figure1,’CurrentAxes’,proyek.axes2);
set(imshow(BW));
set(proyek.axes2,’Userdata’,A);
redo_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)

% — Executes on button press in pushbutton6.
% Code Tombol operator LOG
function pushbutton6_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I=get(proyek.axes1,’Userdata’);
gray=rgb2gray(I);
BW=edge(gray,’log’);
set(proyek.figure1,’CurrentAxes’,proyek.axes2);
set(imshow(BW));
set(proyek.axes2,’Userdata’,A);
redo_Callback(hObject,eventdata, handles);
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% — Executes during object creation, after setting all properties.
function pushbutton2_CreateFcn(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called

Hasil Screenshot :

1. operator Prewitt

Cara Melakukan Operator Laplacian Of Gaussian

2. Operator Robert

Cara Melakukan Operator Laplacian Of Gaussian

3. Operator Canny

Cara Melakukan Operator Laplacian Of Gaussian

4. Operator Sobel

Cara Melakukan Operator Laplacian Of Gaussian

5. Operator LOG

Cara Melakukan Operator Laplacian Of Gaussian

Semoga dengan membaca postingan saya ini dan postingan yang lain diatas anda bisa lebih memahami konsep konsep dasar mempelajari matlab. Untuk itu mungkin sampai sini saja postingan kali ini dan terima kasih telah membaca postinga saya.Sekian dan terima kasih. Salam Dutormasi !

DUTORMASI


Dutormasi menyediakan jasa web development, app development, web design, jasa desain, dan menjual produk yang berguna untuk bisnis online anda. Kami memiliki tim profesional pada bidangnya masing-masing untuk membantu mengembangkan bisnis Anda di dunia digital. Silakan hubungi kami atau klik DISINI untuk mendapatkan informasi lebih lanjut.