[vtkusers] about vtkImageMask

David Gobbi david.gobbi at gmail.com
Mon Jan 14 10:38:02 EST 2008


On Jan 14, 2008 10:20 AM, Sean Ziegeler <seanzig at users.sourceforge.net> wrote:
> >> Could anyone tell me why the mask input in the
> >> vtkImageMask is type "unsigned char"?
> >> I think if it could be bool/bit, it could save a lot
> >> of memory, since we only need values 0 and 1 in a
> >> mask?
> >
> > I'm not a specialist but I would say that booleans are coded on 8 bits
> > (even if they can take only two values). I know no processor capable of
> > handling 1 bit values. So using boolean would _not_ save any memory.
>
> The processor cannot handle single bits directly, but you could write
> code using logical bit operations (bit shifts, bitwise-and's, etc.) to
> pack each bit into a byte and to extract each back out.  It would save
> 8x space, but all the extra ops will probably slow you down by at least
> 8x, if not more.  Also the code would get rather hairy.  All-in-all,
> using bytes is probably better.


If memory is a concern, take a look at the documentation for
vtkImageToImageStencil and the vtkImageStencilFilter.  I added
a special kind of data set to VTK called "vtkImageStencilData"
a while back, the "StencilData" is a run-length compressed binary
image mask. Unfortunately it isn't very well supported yet, but you
can shoot me an email if you have questions about it.

 David



More information about the vtkusers mailing list