[vtkusers] simple vtkLookupTable question
Cory Quammen
cory.quammen at kitware.com
Tue Oct 27 11:15:41 EDT 2015
Richard,
It's actually a little bit involved.
Here's Python code to generate ParaView's Black-Body Radiation color map,
which I think is similar to ImageJ's 'hot' lookup table.
import vtk
cmap = vtk.vtkDiscretizableColorTransferFunction()
cmap.SetColorSpaceToRGB()
cmap.AddRGBPoint(0.0, 0.0, 0.0, 0.0) # black
cmap.AddRGBPoint(0.4, 1.0, 0.9, 0.0) # reddish
cmap.AddRGBPoint(0.8, 0.9, 0.9, 0.0) # yellow
cmap.AddRGBPoint(1.0, 1.0, 1.0, 1.0) # white
scalarValues = vtk.vtkFloatArray()
scalarValues.SetNumberOfComponents(1)
scalarValues.SetNumberOfTuples(256)
for i in xrange(256):
scalarValues.SetTupleValue(i, [i / 255.0])
table = cmap.MapScalars(scalarValues, 0, -1)
for i in xrange(table.GetNumberOfTuples()):
print table.GetTuple(i)
Note that this defines a colormap for scalar values in the range [0, 1].
You can rescale the first arguments to AddRGBPoints() above for a different
scalar range.
Hope that helps,
Cory
On Wed, Oct 21, 2015 at 5:22 AM, mbcx9rb9 <richard.j.brown at live.co.uk>
wrote:
> I imagine this is a very simple question, but I haven't found the answer
> already in the group.
>
> I have greyscale data that I want to apply a lookup table to. Currently, my
> lowest value is red and my highest is blue, but I would like something that
> looks more like the 'fire' lookup table in imageJ.
>
> In essence, I think I want my lowest value to be black and my highest to be
> a red/white. Can anyone give me any pointers?
>
> Thanks in advance,
> Richard Brown
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/simple-vtkLookupTable-question-tp5734493.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
--
Cory Quammen
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151027/ee621d3d/attachment.html>
More information about the vtkusers
mailing list