MATLAB Answers

Ronan
0

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

Asked by Ronan
on 18 Sep 2015
Latest activity Edited by Ronan
on 22 Sep 2015
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.

  0 Comments

Sign in to comment.

3 Answers

Answer by Ronan
on 21 Sep 2015
Edited by Ronan
on 22 Sep 2015
 Accepted 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.

  2 Comments

Again, it would be really helpful to us if you would post example images and code.
Its not a problem anymore. The above worked.

Sign in to comment.


Answer by Jon
on 18 Sep 2015

I do this exact procedure in the context of skeletonizing rivers to find their centerlines. I have to add the ends back after running some erosions to get rid of branches. Unfortunately my algorithm is a little complicated due to the specific constraints I face. Can you provide an example (with images) so we can assist you better?

  0 Comments

Sign in to comment.


Answer by Image Analyst
on 18 Sep 2015

What happened to the original image? Why did it go missing? Anyway, let's say you cleared it for some reason, or it's no longer in scope, and all you have is an image of the endpoints alone, and an image of the skeleton with the endpoints removed. To get the endpoints back, you simply or them:
originalImage = endPointsImage | skeletonImage;

  1 Comment

thanks for that. what i m really trying to do is to isolate separate branches of a skeleton image. So when you get the branch points and subtract from the original image often this single pixel isn't enough to separate the branches. So if you take the branch points and dilate them before you subtract from the original image you can separate the branches properly. So with the isolated branch it is smaller at the ends by 2 pixels so i m trying to get it back to its original size. so if i add back the branch points as single pixels there is obviously a space but if i add back the dilated branch points they are too thick. Maybe there are better ways to isolate the branches and get them back to there original size?

Sign in to comment.