[vtkusers] Image volume conversion
James Carroll
jim at microbrightfield.com
Wed Jun 8 15:35:00 EDT 2005
After looking at the VTK source for TIFFReader I see that it has no
support for multi-tiff.
But I see the ITK does, so I'll try ITK next.
-Jim
________________________________
From: vtkusers-bounces+jim=microbrightfield.com at vtk.org
[mailto:vtkusers-bounces+jim=microbrightfield.com at vtk.org] On Behalf Of
James Carroll
Sent: Wednesday, June 08, 2005 1:45 PM
To: vtkusers at vtk.org
Subject: [vtkusers] Image volume conversion
Hi,
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()
reader.SetFileDimensionality(3)
reader.SetFileName("D:/TestStack.tiff")
# iterate over the entire stack, and see what the min/max of the pixel
# values really is
reader.Update()
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
range.
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.SetScale(256.0)
#scale.SetOutputScalarTypeToChar ( )
# write an 8 bit grayscale tiff stack for the entire volume
writer = vtk.vtkTIFFWriter()
writer.SetFileName("D://wood.tiff")
writer.SetInput(reader.GetOutput())
writer.Write()
# only one plane gets written, and it's totally black
Thanks for the help!
-Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050608/d0b5eb82/attachment.htm>
More information about the vtkusers
mailing list