Neighbour voxels of a list of voxels
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Razakamandimby Tiana
am 18 Mai 2021
Kommentiert: Razakamandimby Tiana
am 20 Mai 2021
I am trying to find all the neighbours voxels of a list of voxels. I already used a function findNeigbours that I downloaded (https://www.mathworks.com/matlabcentral/fileexchange/68549-findneighbours) but it only works for a single voxel and I need to apply the function to a vector.
In my code, I used for loop but it's takiing too long time since the vector list is large. Any solution?
These are the lines I used in my code:
for i = 1:size(vector,1)
surrounding{i} = findNeighbours(vector(i), [[pxl_x, pxl_y, pxl_z], 26)
end
2 Kommentare
KSSV
am 18 Mai 2021
You can use inbuilt functions to achieve this fast. Show us how your voxels are.
Akzeptierte Antwort
Matt J
am 18 Mai 2021
Bearbeitet: Matt J
am 18 Mai 2021
If you have lists of xCoordinates, yCoordinates, and zCoordinates of the voxels, you may simply do,
[dx,dy,dz]=ndgrid([-1,0,1]);
dx=dx(:).'; dy=dy(:).'; dz=dz(:).';
X=xCoordinates(:)+dx; Y=yCoordinates(:)+dy; Z=zCoordinates(:)+dz; %neighbor coordinates
and if the voxel grid has dimensions MxNxP, you might then discard out-of-bounds voxel coordinates by doing,
X(X<1 | X>M)=nan;
Y(Y<1 | Y>N)=nan;
Z(Z<1 | Z>P)=nan;
2 Kommentare
Weitere Antworten (1)
Razakamandimby Tiana
am 20 Mai 2021
2 Kommentare
Matt J
am 20 Mai 2021
But you are using arrayfun. I don't think you could be getting faster speed from arrayfun than with a loop.
Siehe auch
Kategorien
Mehr zu 3-D Volumetric Image Processing 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!