Troubleshooting Isosurface Rendering Code

조회 수: 14 (최근 30일)
Shilpi Ganguly
Shilpi Ganguly 2018년 7월 2일
답변: Anton Semechko 2018년 7월 2일
I had a completely functioning code which created an isosurface with the jet colormap of a binary stack. However today, it will not run no matter what I do and I not sure what is wrong with it! Anyone have any ideas?
if true
% code
end
figure;
a3 = 0.3;
[m,n,p] = size(Image);
[x,y,z] = meshgrid(1:n,1:m,1:p);
z = z.*a3;
z(end) = 10;
[faces,verts,colors] = isosurface(x,y,z,Image,0,z);
p = patch('Vertices',verts,'Faces',faces,'FaceVertexCData',colors,...
'FaceColor','interp','EdgeColor','none');
isonormals(Image,p)
isonormals(x,y,z,Image,p)
daspect([10 10 1])
view(64,17)
axis tight
camlight
lightangle(45,30);
lighting gouraud
grid off
box on
xlim([0 512]);
ylim([0 512]);
zlim([0 10.5]);
set(gca,'XTickLabel',a1*get(gca,'XTick'));
set(gca,'YTickLabel',a2*get(gca,'YTick'));
xlabel('\fontsize{14}{\mu}m')
ylabel('\fontsize{14}{\mu}m')
%set(gca,'xtick',[])
%set(gca,'ytick',[])
zlabel('\fontsize{14}{\mu}m')
colormap jet
c = colorbar;
set(get(c,'title'),'string','\fontsize{14}{\mu}m');
Image is a 525x525x25 logical stack of my image. I keep getting the error
Error using interp3 (line 150) Input grid is not a valid MESHGRID.
Error in isonormals (line 79) n(:,1)=interp3(x, y, z, nx, verts(:,1), verts(:,2), verts(:,3));
This running without any issues a few days ago!

답변 (1개)

Anton Semechko
Anton Semechko 2018년 7월 2일
Make sure that your 'Image' variable is cast as a double and actually has a zero level-set.
Here is an example:
% Sample implicit surface
x=linspace(-5,5,201);
[x,y,z]=meshgrid(x);
F=x.^4 - 5*x.^2 + y.^4 - 5*y.^2 + z.^4 - 5*z.^2 + 11.8;
% Get zero level-set of F
[tri,vrt,col]=isosurface(x,y,z,F,0,z);
% Evaluate surface normals at vrt
N=isonormals(x,y,z,F,vrt);
% Visualize
figure('color','w')
h=patch('Faces',tri,'Vertices',vrt,'FaceVertexCData',col,'FaceColor','interp','EdgeColor','none');
set(h,'VertexNormals',N)
axis equal
view([-44 32])
camlight('headlight')
lighting phong
grid off
box on
colormap('jet')

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by