www.pudn.com > MATLAB.rar > ruihua.m, change:2009-10-20,size:940b


clear; 
close all; 
clc; 
a=imread('2.bmp'); 
figure:imshow(a); 
title('ԭͼ') 
%------------------------ROBERTS-----------------------------% 
b=im2double(a); 
[n1 n2]=size(b); 
for i=1:n1-1 
    for j=1:n2-1 
        b(i,j)=abs(b(i,j)-b(i+1,j+1))+abs(b(i+1,j)-b(i,j+1)); 
    end 
end 
figure:imshow(b); 
title('Robert') 
%-------------------------SABEL------------------------------% 
b=im2double(a); 
[n1 n2]=size(b); 
for i=2:n1-1 
    for j=2:n2-1 
        x(i,j)=b(i+1,j-1)+2*b(i+1,j)+b(i+1,j+1)-b(i-1,j-1)-2*b(i-1,j)-b(i-1,j+1); 
        y(i,j)=b(i-1,j+1)+2*b(i,j+1)+b(i+1,j+1)-b(i-1,j-1)-2*b(i,j-1)-b(i+1,j-1); 
        c=abs(x)+abs(y); 
    end 
end 
figure:imshow(c); 
title('Sabel') 
%------------------------Laplacian---------------------------% 
b=im2double(a); 
[n1 n2]=size(b); 
for i=2:n1-1 
    for j=2:n2-1 
        d(i,j)=b(i+1,j)+b(i-1,j)+b(i,j+1)+b(i,j-1)-4*b(i,j); 
    end 
end 
figure:imshow(d); 
title('Laplacian')