[Paraview] Open a bit image with Paraview

samer at icp.uni-stuttgart.de samer at icp.uni-stuttgart.de
Thu Jul 1 18:27:26 EDT 2010

Hello Eric,

Thanks again that you're the one answering my questions. Well
unfortunately I haven't ever worked on python before, so it would be a
good idea to avoid it in the beginning till I find it the only solution to
my problem. Could you please tell me how you managed to open the bit
images with Paraview and/or VTK? even if it gives some errors, it's OK,
because I'm not asking for so much in the output, I just want to see some
simple 3D visualisation for my images.

Actually I'm surprised, that in VTK I read in the manual that it's
supposed to accept the bit format, but it did not open on paraview when I
tried converting my binary images to VTK format by adding the appropriate
header. So did I miss something in that conversion? The header I added is
the following:

# vtk DataFile Version 3.0
DIMENSIONS 1024 1024 512
ORIGIN 0 0 0
POINT_DATA 536870912
SCALARS OutArray bit 1

Actually this discussion tempts me to ask the question, can I use VTK as a
markup language to open my data files? or should I install this header
into my data file so that both the data and the header are in one file?

Thank you for your time.

Best regards,

> 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