how to calculate width from center line in binary image ?

조회 수: 5 (최근 30일)
anaelle larlet
anaelle larlet 2021년 3월 16일
답변: Hammad Moussa 2021년 5월 27일
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
Adam Danz
Adam Danz 2021년 3월 16일
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".

댓글을 달려면 로그인하십시오.

답변 (2개)

Image Analyst
Image Analyst 2021년 3월 16일
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 2021년 5월 27일
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