[vtkusers] vtkImageIslandRemoval2D,y-z plane,only black area
petr zlamal
p.zlamal.vtk at gmail.com
Sat Mar 28 11:32:17 EDT 2009
Hello VTKuser,
I have some problem with vtkImageIslandRemoval2D in my code. If actor
input is a vtkImageThreshold output, then the scene is rendered and
slices scrolling by keys "n" a "p" are right (in y-z plane). When actor
input is a vtkImageIslandRemoval2D output, then the first slice is
rendered right and next slices are only black. I assume that imageIsland
filter only filling small area and in my configuration
(SetAreaThreshold(0)), would theoretically not have to do anything. Why
all slices (except for the first slice) in y-z plane are black, while
after binary threshold are correct displayed????
Thanks Vepro
My simple code:
#!/usr/bin/env python
import vtk
def KeyPress(obj,event):
global slice
global ia
global ren
global camera
key=obj.GetKeySym()
if (key=="z"):
exit
elif key=="n":
slice=slice+1
ia.SetDisplayExtent(slice,slice,0,320,0,29)
print "You pressed n. Current slice is now",slice
ren.ResetCamera()
renWin.Render()
elif key=="p":
slice=slice-1
ia.SetDisplayExtent(slice,slice,0,320,0,29)
ren.ResetCamera()
renWin.Render()
print "You pressed p. Current slice is now",slice
slice=140
iren=vtk.vtkRenderWindowInteractor()
iren.AddObserver("KeyPressEvent", KeyPress)
reader=vtk.vtkBMPReader() #8bit bmp data set
reader.SetDataExtent(0,320,0,320,0,29)
reader.SetFilePrefix("./bone/bone")
reader.SetFilePattern("%s.%d")
reader.SetDataSpacing(1,1,1)
reader.GetOutput().Update()
ren=vtk.vtkRenderer()
ren.SetBackground(1,0,0)
binthreshold=vtk.vtkImageThreshold() #binary threshold
binthreshold.SetInputConnection(reader.GetOutputPort())
binthreshold.ThresholdBetween(30,255)
binthreshold.SetInValue(255)
binthreshold.SetOutValue(0)
binthreshold.ReleaseDataFlagOff()
island2=vtk.vtkImageIslandRemoval2D()
island2.SetInputConnection(binthreshold.GetOutputPort())
island2.SetIslandValue(0)
island2.SetReplaceValue(255)
island2.SetAreaThreshold(0)
island2.SquareNeighborhoodOn()
ia=vtk.vtkImageActor()
ia.SetInput(island2.GetOutput())
ia.SetDisplayExtent(slice,slice,0,320,0,29)
camera=vtk.vtkCamera()
ren.AddActor(ia)
ren.SetActiveCamera(camera)
camera.Yaw(90)
ren.ResetCamera()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren.SetRenderWindow(renWin)
renWin.Render()
iren.Start()
iren.Initialize()
More information about the vtkusers
mailing list