On Tue, Nov 16, 2010 at 02:19:31PM +0100, moscardi wrote:
> src = mlab.pipeline.scalar_field(im)
> src.update_image_data = True
> contour = mlab.pipeline.contour(src, )
> contour.filter.number_of_contours = int(im.max())

> with im.max = 1041 labels

> Then :
> connect_ = tvtk.PolyDataConnectivityFilter(extraction_mode=6, 
> color_regions=True)
> connect = mlab.pipeline.user_defined(contour, filter=connect_)
> surf = mlab.pipeline.surface(contour,colormap="gist_rainbow")

> If I use "extraction_mode=6", it display only one region. With
> "extraction_mode=5" it display : connect_.number_of_extracted_regions =
> 697, so I haven't all regions.

It's probably the number of contours that is not right, try using
(2*im.max()). VTK has a factor of two (+1?) in the number contours that I
can never understand.

> And finally, when I try to use the picker, I can't update the color of
> the picked region.

Yes, it makes sens.

So, here you have a design problem typical of VTK: to be efficient with
VTK, just like most high-level libraries, you need to think in terms of a
few big problems, rather than many small problems. More concretely, you
need to use one surface module (that will create only one actor) rather
than 1041 surface modules. Now the problem comes when you want to modify
a property of one of these individual units. Often the trick in VTK is to
define a numerical value associated with this property on the object of
interest, for instance the scalar, that you associate with the color,
using the colormap.

Here you want to change this association, so you need to change the
colormap. I think the best approach is to define a custom colormap (as in
the example
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/example_custom_colormap.html
). As you can see in the example, the custom colormap relies on a table
giving the association between values and colors. If you choose that
number to be the same as your number of labels, you can then use the
picker to find the value of the scalar at the location of the pick, and
update this entry in the LUT (as in the example above).

Does that make sens (I need to run to a meeting right now, so these
explaination may be a bit confusing)? I know that this high-level
thinking seems a bit like thinking backward (and it may be) but when you
master it, you can assemble very versatile visualization with little
work.

Gaƫl

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to