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

11 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Ronan
Ronan le 21 Sep 2015
Modifié(e) : Ronan le 22 Sep 2015
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 commentaires
Jon
Jon le 21 Sep 2015
Again, it would be really helpful to us if you would post example images and code.
Ronan
Ronan le 22 Sep 2015
Its not a problem anymore. The above worked.

Connectez-vous pour commenter.

Plus de réponses (2)

Jon
Jon le 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?

Image Analyst
Image Analyst le 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 commentaire
Ronan
Ronan le 21 Sep 2015
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?

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by