voxels inside a 3D convexhull

541 Views Asked by At

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**
1

There are 1 best solutions below

1
On

Assuming that :
- the resolution is not too high (which I assume since you use 3d voxels)
- you are satisfied with an approximate solution
- speed is not an issue

then you may try the option of using morphological operators. By thickening your voxels with a set of rotated thickening structural elements, you end up with an approximate convex hull.

An example of such a calculation in 2D is shown at:

http://homepages.inf.ed.ac.uk/rbf/HIPR2/thick.htm

Otherwise, your option of generating the 3D points and computing a delaunay is also a reasonnable option. You may want to try the code you showed.