Find perimeter of objects in binary image
BW2 = bwperim(BW1)
BW2 = bwperim(BW1, conn)
BW2 = bwperim(BW1) returns a binary image containing only the perimeter pixels of objects in the input image BW1. A pixel is part of the perimeter if it is nonzero and it is connected to at least one zero-valued pixel. The default connectivity is 4 for two dimensions, 6 for three dimensions, and conndef(ndims(BW), 'minimal') for higher dimensions.
Connectivity can also be defined in a more general way for any dimension by using for conn a 3-by-3-by-...-by-3 matrix of 0's and 1's. The 1-valued elements define neighborhood locations relative to the center element of conn. Note that conn must be symmetric about its center element.
Find the perimeter of objects in an image mask.
BW1 = imread('circbw.tif'); BW2 = bwperim(BW1,8); imshow(BW1) figure, imshow(BW2)