MATLAB: How can I obtain Boundary of an image with morphological operators

how can I obtain Boundary of an image with morphological operators? for example my image is A…I want to obtain Boundary and fill Within the image. thanks

Best Answer

I agree with Matt J. If you want an image you could also use bwperim(). To do it morphologically you'd call imerode() to shrink the blobs out one layer, then subtract that from the original
perimImage = binaryImage - imerode(binaryImage);