[vtkusers] Curious about differences in vtkMassProperties for VTK 5.04 and VTK 5.4.2

Francois Bertel francois.bertel at kitware.com
Thu Jun 11 17:42:11 EDT 2009


Hi Azim,

It smells like a broken TIFF reader to me: there were several messages
recently reporting faulty behavior of the vtkTIFFReader.

What happen if you use a different reader?

On Thu, Jun 11, 2009 at 5:26 PM, Azim<azimjinha at gmail.com> wrote:
> 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 ###
> _______________________________________________
> 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 VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list