% DiffEdge: apply Phillips' differential edge detector % % by Will Dwinnell % % Output = DiffEdge(Input,s) % % Output = output image % Input = grayscale image % s = size of analysis template: odd integer >= 3 % % Note: Output is same size as input, edges are padded with zeros % % Reference: % "Image Processing, Part 6: Advanced Edge Detection" % by Dwayne Phillips % "C/C++ Users Journal", Jan-1992 % % Last modified: Mar-23-2007 function Output = DiffEdge(Input,s) % initialize variable Output = zeros(size(Input)); % useful calculation r = floor(s / 2); % radius of analysis template % loop over opposing pixels for i = -r:r-1, % top vs. bottom Output(r+1:end-r,r+1:end-r) = max(Output(r+1:end-r,r+1:end-r),abs(Input(r+1-r:end-r-r,r+1+i:end-r+i) - ... Input(r+1+r:end-r+r,r+1-i:end-r-i))); % left vs. right Output(r+1:end-r,r+1:end-r) = max(Output(r+1:end-r,r+1:end-r),abs(Input(r+1-i:end-r-i,r+1-r:end-r-r) - ... Input(r+1+i:end-r+i,r+1+r:end-r+r))); end % EOF