how to calculate width from center line in binary image ?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello !
my goal is to find the location of my object which has the smallest width.
I did the skeletonization and then I tried to apply bwdist on my image. Then I multiplied the 2 images. But how do I know which is the location with the smallest width ? (because I need to mark and identify this location).
Thank you
close all;
clear all;
clc;
folder = "C:\Users\larle\OneDrive\Documents\Image_chromosomes\testing_matlab2\resultat";
baseFileName = "entite4.png";
fullFileName = fullfile(folder, baseFileName);
im = imread(fullFileName);
im = imsharpen(im);%accentue nettete avec masquage flou
im = medfilt2(im);%filtre median en 2D (reduction de bruits)
thresholdValue=220;
%binarisation
binaryImage = im < thresholdValue;
%skel without extremum
skel= bwmorph(binaryImage,'skel',Inf);
B = bwmorph(skel, 'branchpoints');
E = bwmorph(skel, 'endpoints');
[y,x] = find(E);
B_loc = find(B);
Dmask = false(size(skel));
for k = 1:numel(x)
D = bwdistgeodesic(skel,x(k),y(k));
distanceToBranchPt = min(D(B_loc));
Dmask(D < distanceToBranchPt) =true;
end
skelD = skel - Dmask;
figure(2)
imshow(skelD)
hold all;
edtImage = bwdist(binaryImage);
centerlineImage = double(skelD) .* edtImage;
figure(5)
imshow(centerlineImage)
meanRadius = mean(centerlineImage(skelD))
figure(6)
imshow(meanRadius)
1 Kommentar
Adam Danz
am 16 Mär. 2021
I only see 1 object in your image. Is there supposed to be multiple objects? If not, I don't know what to goal is, "to find the object with the smallest width".
Antworten (2)
Image Analyst
am 16 Mär. 2021
You can use min() to find the min value of the centerlineImage that's not zero. Then use find to find the row and column
minValue = min(centerlineImage(centerlineImage > 0))
[rowOfMin, columnOfMin] = find(centerlineImage == minValue)
0 Kommentare
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!