Azzera filtri
Azzera filtri

how to calculate width from center line in binary image ?

2 visualizzazioni (ultimi 30 giorni)
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 Commento
Adam Danz
Adam Danz il 16 Mar 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".

Accedi per commentare.

Risposte (2)

Image Analyst
Image Analyst il 16 Mar 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)

Hammad Moussa
Hammad Moussa il 27 Mag 2021
how to filtre median and feltre gaussien help me

Community Treasure Hunt

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

Start Hunting!

Translated by