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

13 visualizaciones (últimos 30 días)
M W
M W el 22 de En. de 2020
Comentada: Matt J el 22 de En. de 2020
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);

Respuesta aceptada

Matt J
Matt J el 22 de En. de 2020
Editada: Matt J el 22 de En. de 2020
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 comentarios
Matt J
Matt J el 22 de En. de 2020
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 el 22 de En. de 2020
You must read in all the .tif slices (as grayscale) and organize them as an MxNxP 3D array.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by