How to convert a morphological skeleton from 8-connected to 4-connected?

4 次查看(过去 30 天)
Hello,
Using the image processing toolbox, I was able to obtain a skeleton of cell membranes in a tissue. As expected, the diagonal lines in my binary image are "1-pixel wide". However, in order for my binary image to be compatible with a third-party script, my diagonal lines must be in a "staircase pattern" i.e. they must be 4-connected.
The result obtained with bwmorph's 'diag' operator is close to what I'd like but it produces lines that are too "thick".
I used the following code to obtain my image:
I(I < 250) = 0; % threshold the image
I = imclose(I, strel('disk', 5)); % remove small components
I = bwmorph(I,'skel',Inf); % diagonal lines too thin
I = bwmorph(I,'diag'); % diagonal lines too thick
You will find below images that further illustrate my case.
Any help would be immensely appreciated. Thank you.
---
Skeleton Image:
Thick Image:
Ideal Diagonal Lines (4-connected):

采纳的回答

Image Analyst
Image Analyst 2015-1-20
Use bwhitmiss() to identify places where the pattern is a diagonal. Then add a pixel to the left of right of it. Give it a try and let's see your code if you have trouble.

更多回答(1 个)

martlet
martlet 2015-1-21
Thanks a lot Image Analyst, your answer put me on the right track.

Community Treasure Hunt

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

Start Hunting!

Translated by