Re,

I forget the following code line : 

data = np.where(data[:,:,26:] ==1, 2, 0) 


There are two labels 1 and 2 (0 for the background)

Any ideas?

Thanks,
Eric

On Nov 15, 2010, at 12:06 PM, moscardi wrote:

> Hi,
> 
> I try to display the surface of sphere which is cut in two and I would like 
> that the two hemispheres are independent. 
> 
> For example, I would like to be able to change the color of one half of the 
> sphere.
> 
> But when I try to do that I change the color of two hemispheres : 
> 
> ##############################
> # Code
> ##############################
> 
> import numpy as np
> 
> ##############################
> # Define the sphere cut in two
> ##############################
> 
> xdim, ydim, zdim = 50, 50, 50
> vx, vy, vz = 1., 1., 1.
> R = 25
> cx = 25
> cy = 25
> cz = 25
> 
> data = np.zeros([xdim, ydim, zdim],np.uint8)
> 
> for i in xrange(xdim):
>     for j in xrange(ydim):
>         for k in xrange(zdim):
>             if (i * vx - cx)**2 + (j * vy - cy)**2 + (k * vz - cz)**2 < (R * 
> R) :
>                 data[i,j,k] = 1
> 
> data[:,:,24:26] = 0
> 
> ##########################################################
> # Using of "Tvtk segmentation example" from mayavi 
> # to display the sphere
> ##########################################################
> 
> from enthought.mayavi import mlab
> from enthought.tvtk.api import tvtk
> 
> fig = mlab.figure(bgcolor=(0, 0, 0), size=(400, 500))
> fig.scene.disable_render = True
> 
> src = mlab.pipeline.scalar_field(data)
> src.update_image_data = True
> 
> contour = mlab.pipeline.contour(src, )
> #contour.filter.contours = [1,]
> contour.filter.number_of_contours = 2
> 
> #connect_ = tvtk.PolyDataConnectivityFilter(extraction_mode=4)
> connect_ = tvtk.PolyDataConnectivityFilter(extraction_mode=5)
> 
> connect = mlab.pipeline.user_defined(contour, filter=connect_)
> 
> surf = mlab.pipeline.surface(connect,color=(0.9, 0.72, 0.62))
> 
> ###########################################################
> # Using of the "on_mouse_pick" method of the scene 
> # to change the color
> ##########################################################
> def picker_callback(picker_obj):
>     print  picker_obj.mapper_position
>     print 'try to change the color'
>     picker_obj.actor.property.color = (1,0,0)
> 
> fig.on_mouse_pick(picker_callback,type='cell')
> 
> 
> Is there a way to do that ? 
> What is wrong with my implementation ?
> 
> Thanks for your help.
> 
> Eric 
> 
> 
> 
> ------------------------------------------------------------------------------
> Centralized Desktop Delivery: Dell and VMware Reference Architecture
> Simplifying enterprise desktop deployment and management using
> Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
> client virtualization framework. Read more!
> http://p.sf.net/sfu/dell-eql-dev2dev_______________________________________________
> MayaVi-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mayavi-users

Eric MOSCARDI
INRIA - Virtual Plants
CIRAD, Avenue Agropolis
34398 Montpellier Cedex 5, France
04 67 61 58 00 (ask number 60 09)
email : [email protected]


------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to