|
a |
|
b/theonewith_voxels.m |
|
|
1 |
clear all; close all; clc; |
|
|
2 |
|
|
|
3 |
gridesize=11; |
|
|
4 |
% numbers are arbitrary |
|
|
5 |
cube=zeros(11,11,11); |
|
|
6 |
cube(3:9,3:9,3:9)=5; % Create a cube inside the region |
|
|
7 |
|
|
|
8 |
% Boring: faces of the cube are a different color. |
|
|
9 |
cube(3:9,3:9,3)=1; |
|
|
10 |
cube(3:9,3:9,9)=1; |
|
|
11 |
cube(3:9,3,3:9)=1; |
|
|
12 |
cube(3:9,9,3:9)=1; |
|
|
13 |
cube(3,3:9,3:9)=2; |
|
|
14 |
cube(9,3:9,3:9)=1; |
|
|
15 |
|
|
|
16 |
H=vol3d('Cdata',cube,'alpha',cube/5) %what is alpha? |
|
|
17 |
|
|
|
18 |
figure; |
|
|
19 |
[vol_handle]=VoxelPlotter(cube,0.5); %size of each voxel |
|
|
20 |
view(3); |
|
|
21 |
daspect([1,1,1]); |
|
|
22 |
set(gca,'xlim',[0 gridesize], 'ylim',[0 gridesize], 'zlim',[0 gridesize]); |
|
|
23 |
xlabel('X');ylabel('Y');zlabel('Z'); |
|
|
24 |
|
|
|
25 |
%figure; |
|
|
26 |
%plot3(cube(:,:,1),cube(:,1,:)); |
|
|
27 |
|
|
|
28 |
%connects surfaces with specified value |
|
|
29 |
|
|
|
30 |
figure; |
|
|
31 |
x = 1:11; |
|
|
32 |
y = 1:11; |
|
|
33 |
z = 1:11; |
|
|
34 |
v = cube; |
|
|
35 |
alpha=isosurface(x,y,z,v,1); |
|
|
36 |
p = patch(isosurface(x,y,z,v,5)); |
|
|
37 |
isonormals(x,y,z,v,p) |
|
|
38 |
p.FaceColor = 'red'; |
|
|
39 |
p.EdgeColor = 'none'; |
|
|
40 |
|
|
|
41 |
daspect([1,1,1]) |
|
|
42 |
view(3); axis tight |
|
|
43 |
camlight |
|
|
44 |
lighting gouraud |