How can I extract XYZ data from Isosurface?

I have a 3D array of data. There is a distinct ellipsoid shape in the middle. I would like to extract the coordinate points that describe that ellipsoid. Using the isosurface function, I have found the ellipsoid, and it is correct. Is there a way to extract XYZ coordinate data from the isosurface function? Or, is there a more elegant way to extract 3D coordinate points from a 3D array of data where there is a specific value that comprises the shape?

 Accepted Answer

Why not just use find()?
[rows, columns, slices] = find(array3D == someValue);

9 Comments

If someValue isn't in array3D, then isosurface will do linear interpolation to determinate the location in between grid points.
It's pretty simple. Let's look at an example:
[x y z v] = flow;
q = z./x.*y.^3;
[faces,verts] = isosurface(x, y, z, q, -.08, v);
At this point, the array verts is a 2318x3 array. Each row of the array contains the X,Y,Z coordinates of a point on the surface. The array faces is 4344x3 array of integers. These integers are indices into verts. The 3 values in a row of 'faces' are the 3 points which form a triangle on the surface.
Here's a simple example of looping over all of the faces and drawing each one as a random colored triangle:
for i=1:4344
tri=verts(faces(i,:),:);
patch('XData',tri(:,1), ...
'YData',tri(:,2), ...
'ZData',tri(:,3), ...
'FaceColor',rand(1,3),'EdgeColor','none');
end
camlight
Does that make sense?
Thanks to both of you. The code is functioning now.
I want the same thing as the OP, but I don't see how either of these solves the problem. Since isosurface interpolates, you can't just use find. I'm not sure I follow the example in the comments either. Is that somehow producing the x, y, z coordinates of the desired isosurface? Another way to think about this is the isosurface equivalent of the C2xyz function in the exchange. This tool provides the x and y coordinates of each contour level of a contour. I haven't dug into the code, but I'm pretty sure it interpolates to provide values not originally in the provided data.
Same thoughts and struggles as Daniel suggests here. Any advice or clarification would be welcome.
@Paul Safier, attach your "3D array of data" and since you "I have found the ellipsoid, and it is correct", attach that. Actually I'm not sure why someone can say they sound an ellipse somehow out of a point cloud of all kinds of points, and then not know the indexes of the points that define the ellipse. If you don't have those indexes, then please explain the meaning of "I have found the ellipsoid, and it is correct". What exactly was found (if not the indexes)?
@Image Analyst I think you mean to reply to someone else.
BTW, I had a similar problem and got my answer here.
Paul, since you said "ditto for me" I thought you had a similar problem as the original poster. But I guess not, so just ignore my answer.
On an unrelated note, @Image Analyst , I used your image segmentation tutorial a while back. It's pretty great! Thanks a lot for your contributions to this site!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!