MATLAB: When you dilate and erode a binary image of a skeleton does the skeleton keep its proportion

binary imagebwmorphdilationerosionimageimage processingskeleton

I have subtracted a pixel off the ends of a skeleton on a binary image. To get the skeleton back to the way it originally was I was trying to use dilation and erosion using bwmorph. But I can't seem to get the skeleton back to its original way. It appears that dilation and erosion keeps proportional to the skeleton. All I want to do is add back the pixel that i took off the ends? is this possible without just adding the pixels manually.

Best Answer

So I think I v found a way to do it. Its working for now, but still have to test it out on a bigger scale. So what i did was the following,
% code
Get skeleton image,
Find branch points,
Dilate branch points,
Subtract dilated branch points from skeleton image,
Use connected components with bwconncomp for the broken off branches,
Use regionprops to get get pixel list of each of the branches,
Make an image for an isolated single branch,
Add the image of branch points to the isolated single branch image,
Use dilation to merge the closest branch points to the single branch,
Use thin to put dilated branch points back to single pixels,
use clean to get rid of branch point pixels,
skeleton the remainding single branch,
loop through for all branches
its endpoints are now correctly back to the way they were. So this was only tested on a small scale.