[Paraview] How to do volume rendering of image data?

David E DeMarle dave.demarle at kitware.com
Tue Jul 20 12:02:30 EDT 2010


Unfortunately ParaView only has one-dimensional transfer functions
(and it doesn't handle opacity encoded in the alpha channel directly
all that well either). Please add this as a feature request.

More details for the curious:

We do one-dimensional transfer functions like so:

  rgba' = f(value)

Where value is either a scalar (or a component or magnitude of a
vector to reduce it to a scalar)

You want a two dimensional transfer function. Specifically this very basic one:

  rgb' = rgb, and a' = f(rgb)

Where f is a function of the magnitude of the rgb vector. We can't do
that because rgb and a can't be controlled independently within
ParaView.

The closest hack I could get to doing what you want is:

Apply this python filter to calculate a' = f(rgb):
pdi = self.GetInput().GetPointData()
colors = pdi.GetArray(0)
newcolors = vtk.vtkUnsignedCharArray()
newcolors.SetName("newcolors")
newcolors.SetNumberOfComponents(4)
for i in xrange(0,colors.GetNumberOfTuples()):
  r,g,b = colors.GetTuple3(i)
  o = sqrt(r*r+g*g+b*b)
  newcolors.InsertNextTuple4(r,g,b,o)
pdo = self.GetOutput().GetPointData()
pdo.AddArray(newcolors)
pdo.SetScalars(newcolors)

(Note: producing o as an independent array lets you threshold to get
rid of the blank space in another way, but you still can't produce
rgb' = rgb in the volume rendering of that.)

Then use the slice representation and turn off map and interpolate
scalars to show the directly encoded alpha channel as opacity.

To fake volume rendering I applied the calculator filter then
repeatedly to produce multiple slices. When you look through (in the
right direction) you get a fake volume rendering effect. If you look
the wrong direction alpha blending doesn't work right.





David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109



On Tue, Jul 20, 2010 at 1:53 AM, Steve Huntley <stephen at xhuntley.net> wrote:
> The alpha values are in the lookup table.  Each line in the lookup table has
> four values: red, green, blue, opacity.  That's my understanding of a
> properly formatted lookup table in a vtk file.  I used:
> http://www.vtk.org/VTK/img/file-formats.pdf as a reference.
>
> All opacity values are set to 1.0, except black which is set to 0.0.  But
> when the file is opened in ParaView and volume representation chosen, it
> appears that not only the opacity values but the entire lookup table is
> ignored.
>
> Assuming homogeneous opacity is the furthest thing from what I want.  I want
> to find a way to control opacity without destroying the colors in my image
> data file via mapping to the default color scale.  Getting away from
> homogeneous opacity is what I can't figure out how to do.  I want to see
> through the black background pixels to see the full color pixels of my 3D
> object.
>
> --Steve H.
>
> Moreland, Kenneth wrote:
>>
>> The data you sent has RGB values but no alpha values that I can see.
>>  Volume rendering is generally not very useful if you do not have some
>> representation of opacity.  If you were to assume a homogeneous opacity, you
>> would get a mostly black box with a blob of color in the middle if you
>> looked hard enough.  How exactly you expect the volume renderer to behave?
>>
>> -Ken
>
> _______________________________________________
> 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 ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>


More information about the ParaView mailing list