Alexandre Posted January 3, 2019 Share Posted January 3, 2019 Hi everyone ! As says the title, I want to export scalar values attached to voxels (VDB) into a 3D matrix because I want to access to voxel data into another software (matlab) does someone know how to do that ? thanks ! Alex Quote Link to comment Share on other sites More sharing options...
Alexandre Posted January 3, 2019 Author Share Posted January 3, 2019 (edited) I found some startup ideas here : https://www.sidefx.com/forum/topic/56423/?page=1#post-255419 I use a py node for data export, with vdb visualize tree because the py node from the link export data geometry spread sheet now I need to find how to reshape the vdb_float attribute (in relation to ptnum) from geometry spreadsheet in order to get a 3D matrix (basically, a matrix of 0 and 1 for a binary object) Edited January 3, 2019 by Alexandre Quote Link to comment Share on other sites More sharing options...
Alexandre Posted January 3, 2019 Author Share Posted January 3, 2019 (edited) I will try to reshape data using voxel position Edited January 3, 2019 by Alexandre Quote Link to comment Share on other sites More sharing options...
anim Posted January 3, 2019 Share Posted January 3, 2019 (edited) You can use hou.VDB.voxelRange() to get the array of voxel values Use numpy to reshape it to 3d matrix And export in the format you need Edited January 3, 2019 by anim Quote Link to comment Share on other sites More sharing options...
Alexandre Posted January 3, 2019 Author Share Posted January 3, 2019 thank you !! I have to dive a bit into python coding, but I am sure I will get much quicker to the desire result with your given functions Quote Link to comment Share on other sites More sharing options...
Alexandre Posted January 4, 2019 Author Share Posted January 4, 2019 (edited) Can someone help me on that ? I am diving in python world and found some help using houdini doc : http://www.sidefx.com/docs/houdini/hom/hou/VDB.html I have basically written the function found at the link above, and I try to use this function on my vdb volume (filled inside) but it seems that the object has no attribute 'activeVoxelBoundingBox' :/ I'm 100% sure the problem comes from me, so if someone can put me on the right track I would be grateful thanks Edited January 4, 2019 by Alexandre Quote Link to comment Share on other sites More sharing options...
anim Posted January 4, 2019 Share Posted January 4, 2019 You don't need to write that function as that's what hou.VDB.voxelRange() does, so just use that function But no matter what you have to execute it on the volume prim, not the node Quote Link to comment Share on other sites More sharing options...
anim Posted January 4, 2019 Share Posted January 4, 2019 here is the example connect the Python SOP directly to the geo whose first primitive is the VDB volume you care about import numpy node = hou.pwd() geo = node.geometry() vdb = geo.iterPrims()[0] vdbRes = vdb.resolution() vdbBounds = vdb.activeVoxelBoundingBox() values = vdb.voxelRange(vdbBounds) values = numpy.array(values) values3d = values.reshape(vdbRes, order='F') print values3d 1 Quote Link to comment Share on other sites More sharing options...
Alexandre Posted January 4, 2019 Author Share Posted January 4, 2019 (edited) thank you very much it helps me a lot I am learning a lot from your example Edited January 4, 2019 by Alexandre Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.