I have a cubic matrix of voxels of value 1
(the rest is 0
). I need a matrix of the same size where the voxels INSIDE the convex hull are all of value 1
. I've seen a similar example and adapted it: If I do this to the following, would that work?
% im3D is a cubic matrix of zeros and ones
**[x,y,z]=ind2sub(size(im3D), find(im3D==value));
pointMatrix(:,1) = x;
pointMatrix(:,2) = y;
pointMatrix(:,3) = z;
[K,V] = convhull(x,y,z);
dt = DelaunayTri(pointMatrix);
[X,Y,Z] = meshgrid(1:size(im3D));
simplexIndex = pointLocation(dt,X(:),Y(:),Z(:));
filled_chull = ~isnan(simplexIndex);
filled_chull = reshape(filled_chull,size(X));**
Second question: The voxels inside the convexhull should be all connected right? then why does the following function gives me two connected objects... either euclidean or Manhattan-like / octagon?
**function [nEL, nVOX] = im3D_countobj(im3D,METRIC)
% set METRIC either 'euclidean' or 'octagon'
ES = mmsedisk(1,'3D',METRIC);
q = bwlabeln(im3D,mmseshow(ES));
nEL = max(max(max(q)));
nVOX = size(find(im3D),1);
end**