1

What is the best and low memory option to read a B&W image stack, which contains the 0/1 values of an ISO volume, and write it into boolean voxel array? i.e. 2k images of 2k squared pixels provides 800MB of boolean.

I started writing a 3D boolan array boolean[z,y,x]... and it doesnt work?!: i need an array of 2D arrays boolean[x,y](how ?)

II have already written a program that traverses the stack of images through the X,Y to detect the edge of the volume, i.e. every point in space where the image changes from 0 to 1 and from 1 to 0, and it gives me the vertices and the normals of objects for a poisson disk meshing. I now need to also traverse in Z, without loading 2000 images N times.

The voxel can be up to 8 billion voxels in total.

Which do i need? How can i declare the arrays in C/C#/JS?

Thanks for any tips.

bandybabboon
  • 2,210
  • 1
  • 23
  • 33
  • Is there data at every voxel in the volume? There're lots of results for [voxel data structure](https://www.google.ca/search?q=voxel+data+structure&oq=voxel+data+structure&aqs=chrome..69i57j69i60l2j0l3.3551j0j4&sourceid=chrome&ie=UTF-8). You might benefit from storing your data in some kind of tree. For example: [an octree](https://en.wikipedia.org/wiki/Octree). – Jephron Jan 07 '17 at 23:36
  • Thanks for the suggestion. An octree is very good for fast live representations of subzones of the array, I only wish to read every voxel of the space one time to find the outline of the voxel volume and to convert it to vertices. I found a fast way. – bandybabboon Jan 08 '17 at 02:08

1 Answers1

2

The challenge is to have the smallest data type to represent on/off values for every voxel. Simplify it to a 10x10x10 voxel space.

Its fine to make a 1D boolean array of length 1000, i.e.

var myvoxels : boolean[]= new boolean[x*y*z];

an then to acces it with the function:

function boolreturn(x,y,z) : boolean
{
    return myvoxels[ z*10*10+y*10+x]

}

so the last voxel of size 10x10x10 has array position 900 + 90 + 9 = 999.

it works the same with 100 voxels and with 8 billion of them.

i thought that it was more complicated than that using a 1d array becaues i had converted a marching cubes code which reads every space as modulo and devide/float to know where an object is in the 1d array, which can be mentally taxing and slow to code in 3D. the above should make it easy.

bandybabboon
  • 2,210
  • 1
  • 23
  • 33
  • the max size of the array can be 2147483647 = binary 1111111111111111111 = hexadecimal 7FFF,FFFF16, which is the maximum 32 bit integer. then the z row of the array can function by steps every 2147 million, and it's possible to use librares that have arrays beyond the integer limit. otherwise it's a number overflow. 4 2bn arrays gives over 2000 cubic space using about 10gigs. – bandybabboon Jan 09 '17 at 08:45