Advertisement
Guest User

voxelise problem

a guest
Oct 9th, 2012
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.07 KB | None | 0 0
  1. % create cube that spans points from [1,1,1] to [3,3,3]
  2. vertices = [0 0 0; 1 0 0; 1 0 1; 0 0 1; 0 1 0; 1 1 0; 1 1 1; 0 1 1];
  3. vertices = 2*vertices;
  4. vertices = vertices + ones(size(vertices));
  5. % faces for cube
  6. faces = [1 2 3 4; 2 6 7 3; 6 5 8 7; 5 1 4 8; 4 3 7 8; 1 5 6 2];
  7.  
  8. % display cube
  9. fv.faces = faces;
  10. fv.vertices = vertices;
  11. figure, patch(fv, ...
  12.        'FaceColor','blue','EdgeColor','Black');
  13. view([14,60]); axis vis3d tight
  14.  
  15. % voxelise cube
  16. cubeVolume = VOXELISE(4,4,4,fv);
  17.  
  18. disp(['cubeVolume(2,2,2) should have value 1, but is ' num2str(cubeVolume(2,2,2))]);
  19.  
  20. % display voxelised cube with method provided in VOXELISE_example
  21. figure;
  22. subplot(1,3,1);
  23. imagesc(squeeze(sum(cubeVolume,1)));
  24. colormap(gray(256));
  25. xlabel('Z-direction');
  26. ylabel('Y-direction');
  27. axis equal tight
  28.  
  29. subplot(1,3,2);
  30. imagesc(squeeze(sum(cubeVolume,2)));
  31. colormap(gray(256));
  32. xlabel('Z-direction');
  33. ylabel('X-direction');
  34. axis equal tight
  35.  
  36. subplot(1,3,3);
  37. imagesc(squeeze(sum(cubeVolume,3)));
  38. colormap(gray(256));
  39. xlabel('Y-direction');
  40. ylabel('X-direction');
  41. axis equal tight
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement