Coloring faces of isosurface corresponding to intensities in a 3D plot.

10 ビュー (過去 30 日間)
Kevin Semmelink
Kevin Semmelink 2016 年 4 月 8 日
コメント済み: Kevin Semmelink 2016 年 4 月 9 日
Hello,
I’m trying to determine a way to visualize the intensity of light in a cavity. For this 3D volume cavity I created an isosurface and for all triangles in this isosurface the intensity of light was calculated. I calculated the intensity for the isonormals instead of the individual pixels to simplify the calculations.
I was wondering if it is possible to give every face in the isosurface a color corresponding with its intensity.
There are different ways to color an isosurface, but these are all based on the values corresponding with the volume and not with the values corresponding with the isosurface.
Is there a way to color the isosurface corresponding with the calculated intensities so I can visualize the intensity course?
The code I’ve used to show my segment cavity is as follows:
S = isosurface(Im, 0.5); h = patch(S, 'Facecolor', 'none', 'EdgeColor', 'k');
And the size of the matrix with is as shown below:
Intensity_matrix = [‘number of faces’ ; 1]; %with all intensities corresponding to the faces of the isosurface.
I’m looking forward to one of your answers. Thanks in advance!

採用された回答

Mike Garrity
Mike Garrity 2016 年 4 月 8 日
Yes, you want to set the FaceVertexCData property of the patch object to your data, and the FaceColor property to 'flat'.
Here's a simple example:
%%Create an isosurface
[x y z v] = flow;
p = patch(isosurface(x, y, z, v, -3));
daspect([1 1 1])
view(3)
%%Compute the area of each face
u = p.Vertices(p.Faces(:,2),:) - p.Vertices(p.Faces(:,1),:);
v = p.Vertices(p.Faces(:,3),:) - p.Vertices(p.Faces(:,1),:);
n = cross(u,v);
a = sqrt(n(:,1).^2 + n(:,2).^2 + n(:,3).^2) / 2;
%%Color the faces with the area
p.FaceVertexCData = a;
p.FaceColor = 'flat';
p.EdgeColor = 'none';
Instead of the area, you would use your calculated data. The FaceVertexCData property should be a vector whose length is the same as the number of faces in your patch.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScalar Volume Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by