Created
September 12, 2014 18:38
-
-
Save tonyfast/11fd4ba182ade4f930e3 to your computer and use it in GitHub Desktop.
Edge Detection for Binary Images in Matlab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function edge = binary_edge( image ) | |
| % An approximate algorithm for finding edges in binary images. | |
| % | |
| % The algorithm shifts the images one voxel in each direction. | |
| % It compares the difference betwee the original image and the shifted image. | |
| % Nonzero values indicate edge values | |
| DIMS = ndims(image); | |
| shifts = vertcat( eye(DIMS), ... | |
| -1*eye(DIMS)); | |
| edge = zeros( size( image ) ); | |
| for ii = 1 : size( shifts, 1 ) | |
| edge(:) = edge + ... | |
| abs( image - circshift( image, shifts( ii, : ) ) ); | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment