The gradient strength image at three different smoothing levels.


Gradient Strength Image menggunakan gaussian filter dengan sigma 1


Gradient Strength Image menggunakan gaussian filter dengan sigma 5


Gradient Strength Image menggunakan gaussian filter dengan sigma 10

Listing program :

function GSI = edges(image)

% dapatkan input image
input = imread(image);

% convert image ke grayscale
gray = rgb2gray(input);

% buat filter gaussian
f1 = fspecial(‘gaussian’, size(gray), 1);
f2 = fspecial(‘gaussian’, size(gray), 5);
f3 = fspecial(‘gaussian’, size(gray), 10);

% aplikasikan filter ke image
filtered1 = filter2(f1, gray);
filtered2 = filter2(f2, gray);
filtered3 = filter2(f3, gray);

% dapatkan gradient horizontal dari image
horizontal1 = filter2([-1 0 1],filtered1);
horizontal2 = filter2([-1 0 1],filtered2);
horizontal3 = filter2([-1 0 1],filtered3);

% dapatkan gradient vertikal dari image
vertical1 = filter2([-1; 0; 1],filtered1);
vertical2 = filter2([-1; 0; 1],filtered2);
vertical3 = filter2([-1; 0; 1],filtered3);

% tambahkan gradient horizontal dan vertikal
result1 = horizontal1 + vertical1;
result2 = horizontal2 + vertical2;
result3 = horizontal3 + vertical3;

% tampilkan hasil
imagesc(result1), colormap gray, figure,
imagesc(result2), colormap gray, figure,
imagesc(result3), colormap gray;

An edge map obtained using MATLAB’s edge function

edge dengan threshold 110

edge dengan threshold 125

edge dengan threshold 140
Lising program :

function portofolio5 = edgeMap(input);

% dapatkan input image
image = imread(input);

% convert citra ke grayscale
gray = rgb2gray(image);

% convert citra ke binary dengan 3 nilai threshold yang berbeda
bw1 = im2bw(gray,110/255);
bw2 = im2bw(gray,125/255);
bw3 = im2bw(gray,140/255);

% buat edge map dengan canny
bw1 = edge(bw1,’canny’);
bw2 = edge(bw2,’canny’);
bw3 = edge(bw3,’canny’);

subplot(1,3,1),imshow(bw1);
subplot(1,3,2),imshow(bw2);
subplot(1,3,3),imshow(bw3);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s