How can I get all the cells connected to each individual cells of a Voronoi diagram?

4 Ansichten (letzte 30 Tage)
How can I get all the cells connected to each individual cells of a Voronoi diagram?
I need this to get access to each connected cells while going through all the cells in the image. For example for cell 30 in (fig1), Frist I need to find all the connected object to this cells (e.g. 27,34,42…).
Then I need to call them in a pair (like fig 2) and use them as the mask (m file is attached) over the original image.
I have tried finding closest neighbor (nearestneighbour, good for center points but not the binary objects) and connected regions(bwconncomp) function. I would appreciate getting some advice.
% find the connected objects
[label,n] = bwlabel(maskofVron4Inve);
Bdum=0;
%imshow(label2rgb(label));
for j=1%: max(max (n)) %or NumMask
clearvars 'Cells_ROI_mask' 'totalNoArea' 'Cell_ROI_prop' 'OneByOneLabels' 'BC'
% get each label instead of region of intrest
each_ROI=(label==j);
mask_em = bwareaopen(each_ROI, 40);
%imshow(OneByOneLabels3);
% SegImofFibArea=OneByOneLabels3.*BW_FibMask;
% ImFibMaskinOneRow=sum(SegImofFibArea);
% get the blood ves area and filter its location based on the fib mask
%CenterofVels=(OneByOneLabels3).*(BW_outROIfrombloodV);%BW_outROIfrombloodV2
% ImBloodVesMaskinOneRow=sum(CenterofVels);
end

Akzeptierte Antwort

Peyman Obeidy
Peyman Obeidy am 28 Aug. 2018
Final answer :
I hope this will be helpful.
[label,n] = bwlabel(maskofVron4Inve);
stats = regionprops(label,'Area','BoundingBox','Centroid','Eccentricity','EquivDiameter','Perimeter');%'WeightedCentroid')
stats2Struct=struct2table(stats);
CenterXY=stats2Struct.Centroid(:,:);
for i=1:length(CenterXY)
clearvars nN2
CenterXYasRef=stats2Struct.Centroid(i,:);
[nN,dis] = knnsearch(CenterXY,CenterXYasRef,'k',5);
%sort the distances;
%// Sort the distances
Make_Dis_Tab(:,1)=nN;
Make_Dis_Tab(:,2)=dis;
indx_dis=find(Make_Dis_Tab(:,2)>50 & Make_Dis_Tab(:,2)<200);
Make_Dis_Tab2=Make_Dis_Tab(indx_dis,:);
nN2=Make_Dis_Tab2(:,1);
dis2=Make_Dis_Tab2(:,2);
%// Get the indices of the closest distances
hold on
%end
imshow(Im1);hold on
scatter(CenterXY(:,1),CenterXY(:,2))
plot(stats2Struct.Centroid(i,1), stats2Struct.Centroid(i,2),'y--*','MarkerSize',15);
hold on
line(CenterXY(nN2,1),CenterXY(nN2,2),'color','y','marker','o','linestyle','none','markersize',10)
%waitfor()
pause(1.2);
close
end

Weitere Antworten (1)

KSSV
KSSV am 27 Aug. 2018
Have a look on knnserch. YOu can pick up the 'k' number of nearest neighbors for a given point.
  4 Kommentare
Peyman Obeidy
Peyman Obeidy am 28 Aug. 2018
This is still not exactly what I want.
[label,n] = bwlabel(maskofVron4Inve);
stats = regionprops(label,'Area','BoundingBox','Centroid','Eccentricity','EquivDiameter','Perimeter');%'WeightedCentroid')
stats2Struct=struct2table(stats);
CenterXY=stats2Struct.Centroid(:,:);
for i=1;
CenterXYasRef=stats2Struct.Centroid(i,:);
[nN,dis] = knnsearch(CenterXY,CenterXYasRef,'k',5);
end
imshow(Im1);hold on
scatter(CenterXY(:,1),CenterXY(:,2))
hold on
line(CenterXY(nN,1),CenterXY(nN,2),'color','y','marker','o','linestyle','none','markersize',10)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Voronoi Diagram finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by