[Paraview] Open a bit image with Paraview
Eric E. Monson
emonson at cs.duke.edu
Thu Jul 1 15:18:30 EDT 2010
Hello Samer,
Well, hopefully someone more knowledgeable will speak up if I'm wrong, but after playing around for a while I don't think you're going to be happy with ParaView's support (and probably VTK underneath) for image data with bit attributes. (For example, I couldn't get volume rendering to work, and I got some errors like: vtkOpenGLScalarsToColorsPainter (0x12a099f70): Cannot color by bit array, even though it _would_ actually color it.)
I don't know of a reader offhand that will support single bit data attributes (I tried the old VTK and newer XML-based VTK formats and it didn't work well, and I'm not sure what other readers would work -- the .raw reader in ParaView also seems to have a limit of char at the small end). I have a feeling you could create a custom reader with the Python Programmable Source. You can look at some examples here:
http://www.paraview.org/Wiki/Python_Programmable_Filter
http://www.paraview.org/Wiki/Here_are_some_more_examples_of_simple_ParaView_3_python_filters.
You can create a sample of this type of data directly in ParaView to see what is supported and not with single bit attributes:
1. Create a Wavelet Source
2. Apply a Python Programmable Filter
Use this as the Script:
# ---------------
from paraview.vtk import vtkBitArray
import random
pdi = self.GetInputDataObject(0,0)
pdo = self.GetOutputDataObject(0)
pdo.ShallowCopy(pdi)
ba = vtkBitArray()
ba.SetNumberOfComponents(1)
ba.SetNumberOfTuples(pdi.GetNumberOfPoints())
ba.SetName('bits')
for ii in range(ba.GetNumberOfTuples()):
ba.SetTuple1(ii,round(random.random()))
pdo.GetPointData().AddArray(ba)
pdo.GetPointData().SetActiveScalars('bits')
# ---------------
You can see in the Information tab that a bit array is created, and you can try coloring by that array, but only Slice representation seems to work well. Contour filter seems to deal with it okay, though, so maybe this will still be useful to you.
Talk to you later,
-Eric
------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group
On Jun 30, 2010, at 6:16 PM, samer at icp.uni-stuttgart.de wrote:
> Hello guys,
>
> I have a binary image that consists of bits, every bit indicates to a
> pixel (or voxel) in my 3D image. The file is nothing special, it's simply
> a contiguous file format I write as an output in a C++ program, I mean
> it's not HDF or something common.
> Is it possible to view this image in Paraview without being converted to
> byte for every pixel? I mean is there a way that I could write an XML or
> XDMF script that tells paraview how to view it?
> I succeeded in viewing the image, but after converting every bit to a
> byte, which means that the image is now 8 times bigger in size! this is
> not effective at all I guess.
>
> I would appreciate an example very much.
>
> Thank you
>
> Regards,
> Samer
>
> _______________________________________________
> 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