How to use isosurface to measure volume of the cone??
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
M.S. Khan
am 30 Aug. 2020
Bearbeitet: M.S. Khan
am 31 Aug. 2020
Using code below , i have measure volume of a cone but i want to measure it using isosuface() i.e. using voxels. Can anyone help me please. I will be very thankful.
Thanks in advance for all help.
Regards
R = 10;
h = 20;
N = 10000;
% Generate points in cone
dx = (pi*R^2*h/3/N)^(1/3);
rvec = linspace(-R,R,ceil(2*R/dx));
hvec = linspace(0,h,ceil(h/dx));
[X,Y,Z] = ndgrid(rvec,rvec,hvec);
is_in_cone = (X.^2+Y.^2) <= (R/h*(h-Z)).^2;
x = X(is_in_cone);
y = Y(is_in_cone);
z = Z(is_in_cone);
% Estimate the volume of the 3D object assuming the object is convex
tri = delaunay(x,y,z);
trisurf(tri,x,y,z)
% indices of triangle
i1 = tri(:,1);
i2 = tri(:,2);
i3 = tri(:,3);
i4 = tri(:,4);
%Volume by summing tetrahedron
v1 = [x(i1)-x(i2) y(i1)-y(i2) z(i1)-z(i2)];
v2 = [x(i1)-x(i3) y(i1)-y(i3) z(i1)-z(i3)];
v3 = [x(i1)-x(i4) y(i1)-y(i4) z(i1)-z(i4)];
A = 1/2*cross(v1,v2,2); % surface of a triangle
V = 1/3*dot(A,v3,2); % volume of a tetrahedron
format long
V = sum(abs(V))
0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 30 Aug. 2020
Bearbeitet: Bruno Luong
am 31 Aug. 2020
Theoretical volume = 2094.4, Isosurface estimation = 2092.4.
Pretty good to me.
R = 10;
h = 20;
N = 1e5;
% Theoretical volume
Vol = pi*R^2*h/3
% Generate points in cone
dx = (pi*R^2*h/3/N)^(1/3);
margin = 1e-3;
rmin = -(1+margin)*R;
rmax = +(1+margin)*R;
rvec = linspace(rmin,rmax,ceil((rmax-rmin)/dx));
zmin = -0.5*margin*h;
zmax = (1+0.5*margin)*h;
hvec = linspace(zmin,zmax,ceil((zmax-zmin)/dx));
[X,Y,Z] = meshgrid(rvec,rvec,hvec);
Vcone = sqrt(X.^2+Y.^2) - abs(R/h*(h-Z));
Vcone = max(Vcone,-Z);
Vcone = max(Vcone,Z-h);
[F,V] = isosurface(X,Y,Z,Vcone,0);
% Volume estimated from isosurface
VF = permute(reshape(V(F,:),[size(F) 3]),[3 1 2]);
Vol = 1/6*sum(dot(cross(VF(:,:,1),VF(:,:,2),1),VF(:,:,3),1))
% close all
% isosurface(X,Y,Z,Vcone,0)
% axis equal
% axis([-20 20 -20 20 -10 30])
1 Kommentar
Weitere Antworten (1)
Walter Roberson
am 30 Aug. 2020
I absolutely positively would not use isosurface() to measure volumes. It makes the task into a Computer Vision task, requiring that you take screen captures of the surface from several different angles (6 different angles at absolute minimum), and use Stereo Vision techniques to try to reconstruct depths. It is too many unnecessary complications for too low an accuracy.
Do not do this. Find a different approach.
4 Kommentare
Siehe auch
Kategorien
Mehr zu 3-D Volumetric Image Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!