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

6 ビュー (過去 30 日間)
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.

採用された回答

Ronan
Ronan 2015 年 9 月 21 日
編集済み: Ronan 2015 年 9 月 22 日
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 件のコメント
Jon
Jon 2015 年 9 月 21 日
Again, it would be really helpful to us if you would post example images and code.
Ronan
Ronan 2015 年 9 月 22 日
Its not a problem anymore. The above worked.

サインインしてコメントする。

その他の回答 (2 件)

Jon
Jon 2015 年 9 月 18 日
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 2015 年 9 月 18 日
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 件のコメント
Ronan
Ronan 2015 年 9 月 21 日
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?

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by