Border detection for binary images
B = bwborder(Img)
B = bwborder(Img, 4)
B = bwborder(Img, 8)
Extracts contours from binary images, by detecting which pixel valued 1 has at least one neighbor valued 0. The second argument is 4 or 8 depending if the detection is to be made in 4- or 8-neighborhood. The final border will be 8-connected if 4-neighbors are used, and 4-connected if 8-neighbors are used.
initial_dir = PWD; chdir (SIPDIR + 'images'); Img = imread('star.bmp') clf imshow(Img,2); B = bwborder(Img) imshow(B,2); // exercise: define a small matrix of 0's and 1's, // with the 1's forming a distinct object (like a square), // then run bwborder to see what it does to the matrix. chdir(initial_dir);