[vtkusers] Image volume conversion

James Carroll jim at microbrightfield.com
Wed Jun 8 13:44:39 EDT 2005




I'm trying to do an image stack conversion from a 16bit TIFF with 50
different (multi-tiff style) z planes in it to an 8 bit TIFF, and I'll
want to do some math as a filter in-between.


How can I have it read, filter and write an entire volume?  The
SetFileDimensionality(3) doesn't seem to pick up the different images in
the multi-tiff.


The weired part is that the format is 16 bit unsigned integer, but vtk
GetScalarRange() gives 3.0 to 11.0 which is really narrow, and floating
point?  I know there are more than 8 different pixel intensities.


tiffinfo gives me the following information:

TIFF Directory at offset 0xfaa

  Subfile Type: (0 = 0x0)

  Image Width: 1360 Image Length: 1036

  Resolution: 72, 72 pixels/inch

  Bits/Sample: 16

  Sample Format: unsigned integer

  Compression Scheme: None

  Photometric Interpretation: min-is-black

  Samples/Pixel: 1

  Rows/Strip: 1036

  Planar Configuration: single image plane


Here's my best guess so far, 


import vtk


reader = vtk.vtkTIFFReader()




# iterate over the entire stack, and see what the min/max of the pixel

# values really is


minmax = reader.GetOutput().GetScalarRange()

print "The pixel values fall between", minmax

# this prints float 3.0 to 11.0

# I'm confused why an unsigned integer tiff gives a float scalar

# range, if it's really integer 3 - 11 that's too narrow a dynamic


bounds = reader.GetOutput().GetBounds()

print "The Bounds are", bounds

# prints (0.0, 1359.0, 0.0, 1035.0, 0.0, 0.0)

# I'd expect the z bounds to be 0.0  to 49.0


# eventually...

#scale = vtk.vtkImageShiftScale()

# shift all the 16 bit pixels eight bits to the left


#scale.SetOutputScalarTypeToChar (   ) 



# write an 8 bit grayscale tiff stack for the entire volume

writer = vtk.vtkTIFFWriter()





# only one plane gets written, and it's totally black


Thanks for the help!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050608/2c8a9c8e/attachment.htm>

More information about the vtkusers mailing list