How to define a plane by matrices instead of a function?
17 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
采纳的回答
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
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
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 Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!