How to define a plane by matrices instead of a function?

18 ビュー (過去 30 日間)
M W
M W 2020 年 1 月 22 日
コメント済み: Matt J 2020 年 1 月 22 日
I want to define the following plane which runs through 3 points, by matrices.
So I can use the slice function.
slice(X,Y,Z,V,xslice,yslice,zslice) draws slices for the volumetric data V. Specify X,Y, and Z as the coordinate data. Specify xslice, yslice, and zslice as the slice locations using one of these forms:
  • To draw one or more slice planes that are orthogonal to a particular axis, specify the slice arguments as a scalar or vector.
  • To draw a single slice along a surface, specify all the slice arguments as matrices that define a surface.
I don't know how to define a surface as a matrices.
If you runs this code you will get the function for the plane. Yf.
How to descripe a plane by matrices instead of a function?
A = [104,122,111];
B = [253,122,153];
C = [104,124,111];
normal = cross(A-B, A-C)
syms X Y Z
P = [X,Y,Z];
realdot = @(u, v) u*transpose(v);
plane_function=realdot(P-A,normal);
yf=solve(plane_function,Y)
Yf = matlabFunction(yf) %the PLANE
S = syms;
cellfun(@clear, S);

採用された回答

Matt J
Matt J 2020 年 1 月 22 日
編集済み: Matt J 2020 年 1 月 22 日
For example,
A = [104,122,111];
B = [253,122,153];
C = [104,124,111];
normal=normalize( cross(A-B,A-C),'norm'); %calculate plane parameters
P=dot(A,normal);
load mri %set up some volume data
[X,Y,Z]=meshgrid(1:128,1:128,(1:27)-110);
V = single(squeeze(D));
[x,y]=meshgrid(linspace(1,128,512)); %compute sample locations in plane
z=(normal(1)*x+normal(2)*y-P)./normal(3);
h=slice(X,Y,Z,V,x,y,z,'cubic'); %plot
colormap(gray(256))
h.LineStyle='none';
  2 件のコメント
Matt J
Matt J 2020 年 1 月 22 日
OP's comment moved here:
Thank you, that is exactly what I mean!
However, my 3D image is a .tif image. Which gives the following error:
V = single(squeeze(I));
Error using single
Conversion to single from Tiff is not possible.
Is there another way to use the code?
Matt J
Matt J 2020 年 1 月 22 日
You must read in all the .tif slices (as grayscale) and organize them as an MxNxP 3D array.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by