www.pudn.com > edgeExtraction.rar > prewittEdge.m, change:2012-03-20,size:741b


function edgeImg = prewittEdge( origImg ) 
%UNTITLED Summary of this function goes here 
%prewitt㹫ʽ 
%fx(x,y)=f(x+1,y-1)-f(x-1,y-1)+f(x+1,y)-f(x-1,y)+f(x+1,y+1)-f(x-1,y+1) 
%fy(x,y)=f(x-1,y+1)-f(x-1,y-1)+f(x,y+1)-f(x,y-1)+f(x-1,y+1)-f(x-1,y-1) 
%G[f(x,y)]=[fx^2+fy^2]^0.5 
%   Detailed explanation goes here 
meanImg = (origImg(:,:,1)+origImg(:,:,2)+origImg(:,:,3))/3; 
fx1 = meanImg(3:end,1:end) - meanImg(1:end-2,1:end); 
fx = fx1(1:end,1:end-2) + fx1(1:end,2:end-1) + fx1(1:end,3:end);  
fy1 = meanImg(1:end,3:end) - meanImg(1:end,1:end-2); 
fy = fy1(1:end-2,1:end) + fy1(2:end-1,1:end) + fy1(3:end,1:end); 
edgeImg = sqrt((double(fx)).^2 + (double(fy)).^2); 
edgeImg(find(edgeImg ~=0)) = 255; 
edgeImge = uint8(edgeImg); 
end