I have a stack of images in a 3D matrix.
How can I find 26 neighbors of a specific voxel with coordinates of (i,j,k) in Matlab?
Your help is appreciated.
Thanks
I have a stack of images in a 3D matrix.
How can I find 26 neighbors of a specific voxel with coordinates of (i,j,k) in Matlab?
Your help is appreciated.
Thanks
It's a little unclear what you are trying to do, but this should get you started:
im = rand(256, 256, 10); % image stack
i = 17;
j = 154;
k = 3;
neighborhood = im((-1:1)+i, (-1:1)+j, (-1:1)+k);
neighbors = neighborhood(:);
neighbors(14) = []; % throw away the center voxel
Note that this won't work for voxels on the edge of the volume because they don't have 26 neighbors. What you do in that case depends on what the rest of your code is supposed to do.