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

5 views (last 30 days)
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):

Accepted Answer

Image Analyst
Image Analyst on 20 Jan 2015
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.

More Answers (1)

martlet
martlet on 21 Jan 2015
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!