Find the volume of a nx3 Dataset

Hello everybody, I have an easy question:
I have seen this great explanation about how to integrate the volume underneath a set of nonuniformly spaced data: http://blogs.mathworks.com/videos/2009/09/08/integrating-to-find-the-volume-underneath-a-set-of-nonuniformly-spaced-data/
but the interpolation here it´s done between 0-1 because of his dataset. My question is: if my dataset has a large number of different values (like a ball), how should I do this interpolation? I have thought about to change the
interpZ(0.5,0.5) %test interpolation
vol = quad2d(interpZ,0,1,0,1) %volume should be close to 1
like this:
interpZ(¿?,¿?) %test interpolation
vol = quad2d(interpZ,min(min(z)),max(max(z)),min(min(z)),max(max(z)))
Thank you.

 Accepted Answer

Image Analyst
Image Analyst on 13 Jun 2015
You have to decide what constitutes the "volume". Let's say your N by 3 data are the (x,y,z) coordinates in a scatter cloud/cluster that looks roughly like a peanut. Now, is your 3D volume the bounding box of the peanut? Or do you want it to be the volume of only the peanut itself? Finding the bounding box of the whole peanut is trivial = just use max() and min() on each of the three dimensions, x, y, and z. If you want a peanut shaped volume, then you have to decide if some arbitrary (x,y,z) point is to be included inside the peanut or outside of it, so that if you have a regular grid (like a CT or MRI volumetric image) then you can find the volume of the irregular peanut shape.

11 Comments

My coordinates constitute a segmented tumor, so I want to determinate the volume of this tumor. I have used the convexHull function to plot my 3D tumor and from this function I can get the volume of the convolution. Is it right?
Thanks.
No. The convex hull is like you put a balloon around your object - it does not go into concave parts. If you have a peanut shape, the concave hull of that will be an ellipsoid, which will have a different volume. If the tumor looks like a * (asterisk) the concave hull will be a circle, which has a different area (volume).
So... How could I calculate this volume? If I have the XYZ coordenates of each pixel, then I can calculate the value of each voxel of my image and then multiplicate by the total number of voxels?
I don't know. I'm used to dealing with digital 3-D volume, where the image can be segmented into a binary image and the x,y,z values all occur on a regular grid, like a CT or MRI image. I'm not that familiar dealing with just a list of x,y,z coordinates that can be continuous and not on a regular grid like a volumetric image. Exactly how was this list of x,y,z coordinates generated?
The 'Z component' is the slice's number, and the XY coordinates are the position in the 2D grid. This could be a short example:
X Y Z
46 51 63
47 50 63
47 51 64
49 52 64
49 50 65
51 50 65
50 53 66
But with lots of points.
Then, since you have a regular grid/volumetric image, why isn't the number of voxels "underneath" the Z value just sum(Z(:))? As long as you don't have multiple z values for the same (x,y) location, simply summing the z values will give you the "volume" underneath that z surface and above the Z=0 plane.
Sorry mate but I think I haven't understood you, this volume/voxels thing it's really new for me. To get the volume I will have to consider the 3 variables in every point, or it's not neccesary?
In the simple example I have shown you before, how do you mean you could calculate the volume? sum(Z(:))= 450, but how about the XY coordenates?
Thank you.
You said "integrate the volume underneath a set of nonuniformly spaced data". Do you want the volume under only that data - those locations - or do you want to "fill out" the data to other missing (x,y) locations, and get the volume under those locations also? If you only want data under the existing data, then no, you don't need the other points. Imagine your data was like skyscrapers of a city on some flat plain, and you want the volume of the skyscrapers. Assume unit width of one block for each skyscraper. Do you need to know where the sky scraper is located in the city to know its volume? No, you don't.
But what if you want to drape a huge blanket over the tops of the skyscrapers and assume that the blanket height represents the height of unknown buildings in between the known buildings? Now you will need to interpolate to get/estimate those missing heights, and that will require knowing which (x,y) each building is at. But once you have the building height at each block, you can simply add up the heights to get the volume. At least that's one way. The other way is to assume triangular buildings instead of rectangular blocks, and then you'd have to do something more complicated like using trapz or something.
Ok, it was a great example. I only need to know the volume of my skyscraper, but to know its volume, I have the height (my Z) but I would need the area of the base, and only have some distributed points (my XY). How should I calculate my volume?
If you want the volume in real world units you have to know the width of a voxel. What is your field of view? What is the number of voxels across it? Divide those to get the real world units of a voxel - essentially the cross sectional area. See my attached spatial calibration demo.
Ok, that was the information I hadn't. My providers forgot to add this voxel's width information and I didn't know how could I do it.
Thank you so much, your last message made me realize what was the problem.

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!