[vtkusers] Curious about differences in vtkMassProperties for VTK 5.04 and VTK 5.4.2
Azim
azimjinha at gmail.com
Thu Jun 11 17:26:23 EDT 2009
Hi All,
I have a small python VTK function (pasted in at the bottom of this email) that calculates the volume and surface area of an object embedded in a stack of TIFF images. To read the TIFFs into VTK I have used vtkTIFFReader and processed the result using vtkImageThreshold and vtkImageGaussianSmooth libraries. I then use vtkMassProperties to extract the volume and surface area of the object identified after smoothing and thresholding.
With VTK-5.04, this function returns the correct value for a test stack (3902 pixels). However, the same function returns a different value (422 pixels) when I run it using VTK-5.4.2. Can someone explain this.
Thank you in advance for all your responses/help
Azim
Python Code Below
### Start File ###
import vtk
def testvtk():
# read 36 TIFF images. Each TIFF is 27x27 pixels
v16=vtk.vtkTIFFReader()
v16.SetFilePrefix("d:/test/slice")
v16.SetDataExtent(0,27,0,27,1,36)
v16.SetFilePattern("%s%04d.tif")
v16.SetDataSpacing (1,1,1)
v16.Update()
# Threshold level for seperating background/foreground pixels
maxthres=81
# Threshold the image stack
thres=vtk.vtkImageThreshold()
thres.SetInputConnection(v16.GetOutputPort())
thres.ThresholdByLower(0)
thres.ThresholdByUpper(maxthres)
# create ISO surface from thresholded images
iso=vtk.vtkImageMarchingCubes()
iso.SetInputConnection(thres.GetOutputPort())
# Have VTK calculate the Mass (volume) and surface area
Mass = vtk.vtkMassProperties()
Mass.SetInputConnection(iso.GetOutputPort())
Mass.Update()
# just print the results
print "Volume = ", Mass.GetVolume()
print "Surface = ", Mass.GetSurfaceArea()
testvtk
### End File ###
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090611/2ece2514/attachment.htm>
More information about the vtkusers
mailing list