MATLAB: How to get the inner and outer outlines of a boundary in an image

boundaryImage Processing ToolboxMATLAB

I'm trying to get the inner and outer outlines of the objects in an image to perform ioopl matching according to a paper i'm trying to implement. I want to contract my object boundary inwards and also expand it outward. eg:
how do i do this?

Best Answer

Assuming you have the initial green boundary, you can convert it into a binary image and then use imdilate or imerode to grow or shrink the boundary
mask = poly2mask(x, y, rows, columns);
bigMask = imdilate(mask, true(3));
bigBoundary = bwboundaries(bigMask);
smallMask = imerode(mask, true(3));
smallBoundary = bwboundaries(smallMask);
Change the 3 to some other, larger number if you want to grow or shrink by some different amount.