Image Skeletonisation, Branches and Endpoints

Hello,
I'd appreciate a bit of assistance on counting branches and endpoints in a skeletonised image. I attach the code I'm using below.
CleanedImageImage=im2bw(SegmentedImage);
CleanedImage = bwareafilt(CleanedImage, [4500, inf]);
Count=bwlabel(CleanedImage);
TotalCells=max(max(Count))
Stats = regionprops(CleanedImage,'Area', 'Perimeter', 'MajorAxisLength', 'BoundingBox', 'MinorAxisLength', 'Eccentricity')
Areas = [Stats.Area]/136.89
Perimeters = [Stats.Perimeter]/11.7
MajorAxis = [Stats.MajorAxisLength]/11.7
ResultsTable=struct2table(Stats);
imshow(CleanedImage);
SkelImage=bwskel(CleanedImage,'MinBranchLength',10);
mn=bwmorph(SkelImage,'branchpoints');
[row column] = find(mn);
branchPts = [row column];
cNumBranchPoints = length(branchPts)
endImg = bwmorph(SkelImage, 'endpoints');
[row column] = find(endImg);
endPts = [row column];
cNumEndPoints = length(endPts)
figure;imshow(SkelImage);
hold on ;
plot(branchPts(:,2),branchPts(:,1),'rx');
hold on; plot(endPts(:,2),endPts(:,1),'*');
imwrite(SkelImage,'SkeletonBranchEndpts.jpg');
OutOverlay=imoverlay(InputImage,(im2bw(SkelImage)));
t=struct2table(Stats);
writetable(t,'regionprops.csv');
I'm taking a segmented image in and removing some artifacts, then labelling it and counting the objects. Then I'm getting some measurements on the objects, before skeletonising it to get a count of branches and endpoints.
1. I can get a total count of branches and endpoints, but I want to get this count per object in the image, and not in total. Then want to add this as two additional columns in the table I'm saving at the end.
2. I'm displaying Areas, peimeter and major axis in the command window, as theres a scaling factor to be applied. When I write the table with the results, the output is in pixels, and not converted with the scaling factor. How can I achieve this - do I write back the [Stats.Area] into regionprops before saving?
3. Finally - I'm marking the branchpoints and endpoints with asterisks towards the end, and superimposing my skeleton image on the original image to estimate how well the skeletonisation has performed. However, the asterisks from the plot are always missing. What do I need to do to ensure they are written into the output image.

Respuestas (0)

Preguntada:

el 26 de Feb. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by