November 22, 2008

pembuatan sobel menggunakan mathlab

listing program sobel:
clear all
I=imread('nodules1','tif');
figure(1),imshow(I);
%[N,M]=size(I);
%for i=1:N-1
% for j=1:M-1
% Gx(i,j)=I(i,j)-I(i,j+1);
% Gy(i,j)=I(i,j)-I(i+1,j);
%G(i,j)=abs(Gx(i,j))+ abs(Gy(i,j));
%end
%end

%figure(8),imshow(G);
Gx=[1 1 1
0 0 0
-1 -1 -1];
Gy=[-1 0 1
-1 0 1
-1 0 1];
G1=conv2(I,Gx);
G2=conv2(I,Gy);
figure(8),imshow(G1);
figure(9),imshow(G2);
G=abs(G1)+abs(G2);
figure(10),imshow(uint8(G));

Ouput:

file asli:


hasil sobel 1:



hasil sobel 2:


Hasil sobel 3: