Professional Documents
Culture Documents
Listing Program:: RGB Grayscale Filter Mean Edge Detection
Listing Program:: RGB Grayscale Filter Mean Edge Detection
NIM : 1657301050
Kelas : TI 3.2
Listing Program :
clc
%RGB
baca = imread('farhan.jpeg');
%Citra Abu
abu = rgb2gray(baca);
%Mean Filter
filmean = imfilter(abu,h,'replicate');
%Deteksi Tepi
%Robert
Rx = [1 0 ; 0 -1 ];
R_Icx = filter2(Rx,filmean);
R_ver = R_Icx/255;
Ry = [0 1; -1 0 ];
R_her = R_Icy/255;
grad_R = R_edge_p/255;
%Sobel
Sx = [-1 -2 -1 ; 0 0 0 ; 1 2 1];
S_Icx = filter2(Sx,filmean);
S_ver = S_Icx/255;
Sy = [-1 0 1 ; -2 0 2 ; -1 0 1];
S_Icy = filter2(Sy, filmean);
S_her = S_Icy/255;
grad_S = S_edge_p/255;
%Prewitt
Px = [-1 -1 -1 ; 0 0 0 ; 1 1 1];
P_Icx = filter2(Px,filmean);
P_ver = P_Icx/255;
Py = [-1 0 1 ; -1 0 1 ; -1 0 1];
P_her = P_Icy/255;
grad_P = P_edge_p/255;
imtool(baca);
imtool(abu);
imtool(filmean);
imtool(grad_R);
imtool(grad_S);
imtool(grad_P);
RGB → GrayScale :
RGB
GrayScale
(X,Y) RGB RGB → GrayScale
(X,Y) RGB RGB → GrayScale
GrayScale → Filter Mean :
GrayScale
Filter Mean
(X,Y) GrayScale → Filter Mean
(X,Y) GrayScale → Filter Mean
Filter Mean → Edge Detection (Operator Robert):
Filter Mean
Filter Mean
Filter Mean