-2

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

S.EB
  • 1,966
  • 4
  • 29
  • 54

1 Answers1

0

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.

Tokkot
  • 1,215
  • 7
  • 22
  • thanks for your response. I have a big feature set matric (7584692x137) that I want to extract indices of neighbors to retrieve from my feature set matrix. How can I obtain the indices of neighbors? – S.EB Nov 05 '16 at 12:59