Creating a 3D image from the 3D data points

I have a dataset of 3D "grayscale" images (medical ultrasound dataset) in the form of cartesian coordinates of each voxel and according grayscale intesity values. I want to convert this data to the 3D image matrix (so that it can be used in matlab programming).
I have seen a similar function but for "plotting" named "pcolor" for "2D" images. I want that the output be a "3D" image "matrix" and I don't want only to visualize tha data, so this function is not useful.
-Do you know whether the matlab image processing toolbox (or file-exchange resources,...) has a function that can perform such conversion?
-If the suitable function does not exist in image processing toolbox, how I can program this conversion using matlab? I think that I must do some sort of interpolation, but I don't know exactly how to do it.
your help and comments are greatly appreciated I am looking forward to receiving responses

回答(3 个)

If you have, or can put, your voxels in a simple plaid grid the matlab function to try first is slice. Then there are a bunch of tools for volume visualization/rendering on the file exchange:
For working with transparency I've had mixed success with matlabs alpha-functions, typically I've tried something like:
alphamap('rampdown');alphamap(0.3 .* alphamap);

8 个评论

Sorry, you didn't understand the problem correctly.My problem is that "I don't have the matlab image" I have a set of (floating point)coordinates and intensity values only. a matlab image is a matrix, and I don't have such a matrix. I don't want to visualize o render the data. I want to work on this image using image processing toolbox, but before using the toolbox I must have the image matrix. so above links is not useful for me.
thank you.
In addition to the tools Walter points to below you might have to use delaunay3 if you're using a slightly older version of matlab.
Or if your cartesian coordinates are on a plaid grid you could simply do something like this to build your voxel volume:
V = zeros([n1,n2,n3]); % Pre-allocate...
for i1 = 1:n1, % number of points along dim #1
for i2 = 1:n2,
for i3 = 1:n3
V(i1,i2,i3) = YourData(CorrespondingIndices);
end
end
end
Also, "want to work on this image with IP toolbox" is kind of vague - but for some operations you might have to work on 2-D slices, others support 3-D images.
If your cartesian coordinates fall are multiples of a discrete interval apart, but are simply not complete (or not ordered), you can put them in to an gridded array (with no interpolation) by using accumarray() . The index you would use for any one coordinate would be 1 + round((actual coordinate minus minimum coordinate) / coordinate spacing)
Dear "Walter Roberson" and "Bjorn Gustavsson"
My datapoints are random scattered points in 3D space, some are near and some are far apart, obviously some points are missing the data and they must be interpolated using adjacent datapoints.
you simplified the problem, and then solved it, the answer of the all "if" sentences in your comments is : no, it is not the case...
"want to work on this image with IP toolbox" is not vague, because before using the IP toolbox you must have an image: SIMPLY, I DON'T HAVE AN IMAGE!
thank you, but it is not the right answer.
My earlier response about interp3 does not assume the data points are any particular distance apart. You did not respond to that, did not at that time provide the further information about the distribution. Then when Bjorn conditionally proposed a mechanism, making it clear under what conditions it would apply, I offered a refinement of that mechanism, also making it clear under what conditions that would apply.
When you provide all relevant information from the beginning, the risks of getting sidetracked are reduced.
You are not going to be able to use the image processing toolbox directly, as your array will be a 3D array that is not an RGB image. The image processing toolbox can only work directly on arrays that are either 2D (grayscale or binary), or 3D where the 3rd dimension is 3 (R, G, B channels.) (Though there are a couple of things that IPT can do with M x N x 4 arrays that are CMYK)
Dear Walter
Ok, so I understand that the most of IP toolbox operations are 2D. This is a bad news. I must try your other answer then I will comment it.
Thank you very much
Sure hell it is vague. You could analyse away on images in all sorts of directions with the IP toolbox and two persons setting off in different directions might never use the same special functions again. To correct myself I should have suggested griddata3 for you to use if your version of matlab does not have triscatteredinterp.
Dear Bjorn
Yes, I accept, that was vague. I think the griddata3() is a good suggestion. I will try the "griddata3()" function and I will report the result.
Thank you very much.

请先登录,再进行评论。

You might be able to use interp3() to convert your data to a grid.
Depending exactly what you want to do with the data, you might find triscatteredinterp to be more useful.

2 个评论

Yes, I think that I can use the interp3() function, the second suggestion (triscatteredinterp) is interesting, but I think this can be applied on 2D images.
Thank you.
If your data points are randomly scattered in 3-D then your best start is to interpolate them to a plaid grid with griddata3. If I recall correctly interp3 expects the input data to be on a plaid grid already.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Images 的更多信息

提问:

2011-9-4

Community Treasure Hunt

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

Start Hunting!

Translated by