Jason Posted May 25, 2011 Share Posted May 25, 2011 Hi all, Ever since I read about the functionality in scipy, I've wanted to see how it could enhance volumes in Houdini. So I suddenly realized our Systems people here at work installed it sometime or other and it was available within HOM! Woo! Anyhow, please see how easy this is... and useful. Here is the code of the SOP too: import numpy import scipy import scipy.ndimage # This code is called when instances of this SOP cook. geo = hou.pwd().geometry() # Add code to modify the contents of geo. prim_number = hou.pwd().parm("prim_number").eval() volume = geo.prims()[prim_number] np = numpy.array(volume.allVoxels()).reshape(volume.resolution()) # Now we have our numpy 3d array... have fun! if hou.pwd().parm("do_gaussian").eval(): sigma= hou.pwd().parm("gaussian_sigma").eval() np = scipy.ndimage.filters.gaussian_filter( np, sigma ) if hou.pwd().parm("do_uniform").eval(): uniform_size = hou.pwd().parm("uniform_size").eval() np = scipy.ndimage.filters.uniform_filter( np, uniform_size ) if hou.pwd().parm("do_sobel").eval(): np = scipy.ndimage.filters.sobel( np ) if hou.pwd().parm("do_prewitt").eval(): np = scipy.ndimage.filters.prewitt( np ) if hou.pwd().parm("do_abs").eval(): np = abs(np) # set the values of the volume back in Houdini volume.setAllVoxels( np.flatten() ) I hope someone finds this useful in some way. In fact I was surprised at the speed of this thing: a 100^3 volume gets sent to scipy and filtered and returned to Houdini in about 1 second! Take care, Jason scipy_volumefilter_v1.otl 2 Quote Link to comment Share on other sites More sharing options...
zarti Posted May 25, 2011 Share Posted May 25, 2011 (edited) i thought ( or even read , esp about numpy ) that this wasn't possible , but hey .. glad to see it is 'working' . thank you Jason ! looks fun and fast too .. =) .cheers Edited May 25, 2011 by zarti Quote Link to comment Share on other sites More sharing options...
graham Posted May 25, 2011 Share Posted May 25, 2011 There's an example of using numpy on the HOM doc page about writing a COP operator. http://www.sidefx.com/docs/houdini11.0/hom/pythoncop Quote Link to comment Share on other sites More sharing options...
Jason Posted May 25, 2011 Author Share Posted May 25, 2011 There's an example of using numpy on the HOM doc page about writing a COP operator. http://www.sidefx.com/docs/houdini11.0/hom/pythoncop Ah, that would have helped me figure out the ...AsString() method, had I known about this beforehand! Now wouldn't it be fun to write a Python VOPnet context in which we could process volumes, rasters, etc? Or does that exist somewhere already, Mr.Thompson? Quote Link to comment Share on other sites More sharing options...
Jason Posted May 26, 2011 Author Share Posted May 26, 2011 There are also some nice scipy.spatial.KDTree and Delauney routines available; for those who can't wait until SESI create HOM functions for UT_KDTree and such. Quote Link to comment Share on other sites More sharing options...
graham Posted May 26, 2011 Share Posted May 26, 2011 Attached is a HOM_PointTree class I created that wraps around the KDTree implementation. It's designed to be kind of similar to GEO_PointTree in that it takes a hou.Geometry input and builds a tree you can then query using a hou.Vector3 object to get the nearest N points, or points within some distance. It returns tuples of hou.Points as the result. treeutils.zip Quote Link to comment Share on other sites More sharing options...
Jason Posted May 26, 2011 Author Share Posted May 26, 2011 Great stuff! Quote Link to comment Share on other sites More sharing options...
rdg Posted May 26, 2011 Share Posted May 26, 2011 Sweet! Are there R-Trees as well? Quote Link to comment Share on other sites More sharing options...
zarti Posted September 20, 2011 Share Posted September 20, 2011 i thought ( or even read , esp about numpy ) that this wasn't possible , .. .. which results to be pretty easy in Ubuntu . .cheers Quote Link to comment Share on other sites More sharing options...
dulo Posted October 14, 2011 Share Posted October 14, 2011 Created x64 builds for windows of numpy, scipy, vtk and opencv (CUDA). If you are interested in testing take a look at http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&p=109229#109229 greetings dulo Quote Link to comment Share on other sites More sharing options...
sibarrick Posted October 13, 2013 Share Posted October 13, 2013 When I try and import scipy I just get an error, has this been removed from Houdini since H12.5? Quote Link to comment Share on other sites More sharing options...
ikarus Posted October 13, 2013 Share Posted October 13, 2013 numpy/scipy are external python libraries not included in houdini Quote Link to comment Share on other sites More sharing options...
graham Posted October 13, 2013 Share Posted October 13, 2013 I don't think it was ever shipped with Houdini. Has your system python configuration changed since you last tried (assuming you are on linux) ? 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.