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

조회 수: 17 (최근 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개)

Community Treasure Hunt

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

Start Hunting!

Translated by