Question

I need a function to get the value of a voxel (3d pixel) from a X.volume object, given the x,y,z coords as an input. This is to use a lablemap as a reference for an atlas function. Is there a way to do this?

Many thanks,

Edward

Was it helpful?

Solution

Currently no, though the XTK developers are creating something similar as explained in Finding world coordinates from screen coordinates, though what I believe whats being done there is an Unproject function and Ray/Triangle intersection test. A Ray/Triangle intersection tests justs casts a Ray from your screen into the 3d world and returns the first intersected triangle coordinates, but of course you need to find the voxels. You can try creating an Unproject function and something similar to the Ray/Triangle intersection but instead finding the closest intersected voxel instead of triangle. Help with an Unproject function is here http://myweb.lmu.edu/dondi/share/cg/unproject-explained.pdf, but rememeber that link explains GluUnproject from OpenGL, but still explains what we need to do, we are just making an alternative version of GluUnproject for WebGL. Any solutions you may find would be greatly appreciated if contributed to XTK. Or you may wait on the Unproject function that may possibly come from the related problem in finding the 3d coordinates.

OTHER TIPS

What are your (x,y,z) ? Are they the coordinates in the world's basis or in the volume's basis ? In both case a solution could be computed (it will be a bit more complicated in the 1st case) but I think it would require a few changes in the sources.

Do you want to code a bit in the sources and participate ? It would be great for xtk users like us ! You'd just to go through the volume's hiearchy and to do a few operations :

  • If (x,y,z) are coordinates in the world's basis : complicated. Must do some tests :-)
  • Choose a direction to work in ( 1 volume can have slices in 3 directions), for ex slicesX for the 1st direction
  • With the volume's center X coordinate, the volume X spacing, and the X coordinate of the picked point find the good slice in slicesX
  • With the volume's center (y,z), the volume Y and Z spacing, and the Y and Z coordinates of the picked point get the (x',y') coordinate on the choosen slice's texture map
  • With the choosen slice's texture size get (x'',y'') the coordinates on the slice's texture image
  • Read the (x'',y'') point of the texture

I'm sorry I've not time to look further this week, but maybe later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top