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

조회 수: 4 (최근 30일)
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

채택된 답변

Peyman Obeidy
Peyman Obeidy 2018년 8월 28일
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

추가 답변 (1개)

KSSV
KSSV 2018년 8월 27일
Have a look on knnserch. YOu can pick up the 'k' number of nearest neighbors for a given point.
  댓글 수: 4
Peyman Obeidy
Peyman Obeidy 2018년 8월 28일
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)

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

카테고리

Help CenterFile Exchange에서 Voronoi Diagram에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by