MATLAB: Whole body skeleton segmentation

digital image processingimageimage analysisimage processingImage Processing Toolboximage segmentationMATLAB

I want to extract the skeleton of the image I attached so that I can use it as a mask on that image. A simple threshold does not do it because I need every part of bone region to be filled. This is what I've done so far. With this code there are some parts of the skeleton that are not filled (and should be) and some parts that do not belong to the skeleton that are included in the mask (and should be). Any suggestions?
Thanks in advance.
imgGray = readdicom(imgPath); %a function I made to read the image
imgAdjust = imadjust(imgGray); %, [0 0.2]
BW = imgAdjust > 0.17; %threhold
BW2 = medfilt2(BW, [5 5]);
se = strel('disk',3);
close = imclose(BW2,se);
closeFill = imfill(close,'holes');
src = imgAdjust;
mask=closeFill;
masked = bsxfun(@times, src, cast(mask,class(src)));
imshow(masked)
subplot(131), imshow(src), title('Original');
subplot(132), imshow(mask), title('Mask');
subplot(133), imshow(masked), title('Masked');

Best Answer

If there is no signal there, then of course it won't be found so there's nothing you can do unless you want to "invent" data by doing edge linking or interpolation or something. You could try adapthisteq() or adaptthresh() but for that image, I think a low global threshold should be best. Again, if the signal is zero, there is no signal there and it shouldn't find anything.