I have a grid, it is 3D and it stores a number.
Here is an example of my grid if it is 2*2*2:
(:, :, 1) -> [0, 0;
0, 0]
(:, :, 2) -> [0, 0;
0, 0]
The number 0 would usually be a number that I would like to represent with colour or nan if no voxel exists there. What i would like to do is display a voxel grid with matlab like in the following picture:
Except that the vocels should be coloured with the number in the cell.
Does anyone know how to do this, if there is a library or some way to write it myself?
So I found out you can do it like this:
for x = 1:GridSize(1)
for y = 1:GridSize(2)
for z = 1:GridSize(3)
if (~isnan(VoxelGrid(x, y, z)))
cubeLength = VoxelGrid.resolution;
plotcube( [cubeLength cubeLength cubeLength], ...
[x, y, z], ...
0.9, ...
[colour, colour, colour])
end
end
end
end
This will print out a grey scale voxel representation like this:
Now i just need some help getting the colour working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With