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

7 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Ronan
Ronan il 21 Set 2015
Modificato: Ronan il 22 Set 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.

Più risposte (2)

Jon
Jon il 18 Set 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 il 18 Set 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 Commento
Ronan
Ronan il 21 Set 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?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by