Anda di halaman 1dari 2

Najmi 1306415844

Tugas UTS SMV


Kasus:
Pendeteksian segala bentuk serangga

Dilakukan dengan cara


Convert gambar menjadi BW -> Rubah Menjadi gambar biner -> Dilatasi gambar ->Mengisi holes ->
Segmentasi gambar -> Menampilkan segmen gambar dengan gambar asli
Coding
clc
clear all
close all
a = imread('housepests.jpg');
I=im2bw(a);

[~, threshold] = edge(I, 'sobel');


fudgeFactor = .5;
BWs = edge(I,'sobel', threshold * fudgeFactor); % membuat gambar menjadi
biner
se90 = strel('line', 3, 90);
se0 = strel('line', 3, 0);
BWsdil = imdilate(BWs, [se90 se0]);

Najmi 1306415844
Tugas UTS SMV
BWdfill = imfill(BWsdil, 'holes'); %mengisi holes
BWnobord = imclearborder(BWdfill, 4);
seD = strel('diamond',1);
BWfinal = imerode(BWnobord,seD);
BWfinal = imerode(BWfinal,seD); % segmentasi gambar
BWoutline = bwperim(BWfinal);
Segout = a;
Segout(BWoutline) = 255;
subplot(1,2,1)
imshow(a), title('Gambar Original');
subplot(1,2,2)
imshow(Segout), title('Gambar Dengan Outline');

Anda mungkin juga menyukai