[Paraview] Lookup Table Range

David Pont David.Pont at scionresearch.com
Sun Apr 18 20:18:35 EDT 2010


Thanks for the tips Eric, I will look into these techniques although for a Paraview scripting newbie this is quickly getting in over my head!

Meanwhile I started on another approach, which may also benefit from the techniques you have pointed me to. I saved a LUT from the Paraview GUI (Edit Color Map | Choose Preset | Export) and used this as an example to help me write a custom LUT for each scalar and save it in an xml file. I can then Import the LUT into Paraview, but only in interactive mode, I'd really like to be able to script it all so I can automatically generate an image for each scalar.

I took things further than just a compressed range and constructed a LUT for each scalar based on histogram equalisation of the scalar data. This works great and will be a more general solution for data with arbitrary distributions. But how to automate it all ! I Also must poke around and check there is a filter in Paraview (or vtk) already that does histogram equalization. The topic is covered in the vtk book, and would seem to be a useful visualisation trick. A quick peek on Google suggests 'maybe' in ITK... so I may be doing this myself after all.

I am making progress and your tips may well be good pieces for my jigsaw.

  regards, Dave

From: Eric E. Monson [mailto:emonson at cs.duke.edu]
Sent: Thursday, 15 April 2010 5:43 a.m.
To: David Pont
Cc: paraview at paraview.org
Subject: Re: [Paraview] Lookup Table Range

Hey Dave,

If you want to retrieve the attribute data to make the calculations then you can call

servermanager.Fetch()

to pull from the server to the client. You can see examples on:

http://www.cmake.org/Wiki/ParaView/Python_Scripting

If your data is very large, though, it might be tough to do this. If you look at the above page it talks about passing algorithms as the optional arguments, like vtkMinMax, which will process the data on the server and send a result to the client. I'm not sure all of what would be involved (probably making a plugin that you can load with your custom class), but you may be able to make a quantile filter in place of vtkMinMax and pass that to Fetch().

Another thing I've done is to use a Python Programmable Filter (PPF) to do something similar to what vtkMinMax is doing: Calculate statistics on my data set and output a single point which has the calculated attributes (such as mean of all input attributes). Maybe you could just output a two-point polydata from your PPF in which each point contains the 5 and 95 percentiles for every attribute, and then Fetch that data to set the LUT ranges?

Hope this helps,
-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Apr 13, 2010, at 1:00 AM, David Pont wrote:


I am developing a python script to visualise point data (unstructured grid) with a large number of scalar values for each point.
My problem is some of the scalar data is a bit noisy, i.e. a histogram of the values has a long tail at one or both ends, which effectively reduces the useful range of color in the visualisation. I would like to determine the 5 and 95 percentiles for each data array and use these as the range for the LUT. And I would like to do this from my python script. I can't figure out how to get at the underlying point data, as it would then be very easily to calculate a restricted range.
See my current script below.

Thanks in advance for any help, Dave


####################################################
from paraview.simple import *

sm = servermanager
sm.Connect()

INPUTFILES = ("Esk all trees v2.txt_1.vtk", "Esk all trees v2.txt_2.vtk", "Esk all trees v2.txt_3.vtk")

# create reader for legacy VTK files
reader = LegacyVTKReader(FileNames=INPUTFILES[2])

#create and configure view window
Show()
view = GetActiveView()
#set the background color
#view.Background = [1,1,1]  #white
#set window size
view.ViewSize = [800, 600]
view.UseOffscreenRenderingForScreenshots = True

# set basic display properties
dp = GetDisplayProperties()
#set representation
dp.Representation = "Points"
#dp.Representation = "Surface"
#set point size
dp.PointSize = 2
dp.MapScalars = True
dp.InterpolateScalarsBeforeMapping = True

# create a legend
bar = servermanager.rendering.ScalarBarWidgetRepresentation(registrationGroup='scalar_bars', registrationName="ScalarBarWidgetRepresentation1")
#bar.LabelColor = [1.0, 1.0, 1.0]
#bar.TitleColor = [1.0, 1.0, 1.0]
bar.TitleFontSize = 10
bar.LabelFontSize = 10
view.Representations.append(bar)

# render and save image for each scalar array in the point data
for a in reader.PointData :
                print a.GetName()
                r = a.GetRange()
                dp.LookupTable = MakeBlueToRedLT(r[0], r[1])
                dp.ColorAttributeType = 'POINT_DATA'
                dp.ColorArrayName = a.GetName()
                bar.Title = a.GetName()
                bar.LookupTable = dp.LookupTable
                Render()
                #save screenshot
                WriteImage( "v%s.jpg" % (a.GetName()) )

________________________________
Disclaimer: This e-mail and any attachments may contain information which is confidential or subject to copyright. If you receive this e-mail in error, please delete it.
Scion does not accept responsibility for anything in this e-mail which is not provided in the course of Scion's usual business or for any computer virus, data corruption, interference or delay arising from this e-mail.
_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects athttp://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at:http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview


________________________________
Disclaimer: This e-mail and any attachments may contain information which is confidential or subject to copyright. If you receive this e-mail in error, please delete it.
Scion does not accept responsibility for anything in this e-mail which is not provided in the course of Scion's usual business or for any computer virus, data corruption, interference or delay arising from this e-mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100419/de35836c/attachment-0001.htm>


More information about the ParaView mailing list