[vtk-developers] imaging pipeline bug
dean.inglis at camris.ca
dean.inglis at camris.ca
Mon Jan 3 11:33:01 EST 2005
Hi,
a while back, I had developed a pipeline
for polygonal region of interest analysis
of 2D images using:
vtkImageData -> vtkImageTracerWidget
| |
| vtkPolyData
| |
| vtkLinearExtrusionFilter
| |
| vtkPolyDataToImageStencil
| | |
vtkImageStencil |
| |
vtkImageMapToWindowLevelColors |
| |
vtkImageActor vtkImageAccumulate (rev. 1.51)
With recent revisions (after conversion to the new pipeline), the pipeline
crashes in both .cxx and .tcl test codes upon requesting image stats
from vtkImageAccumulate (e.g. GetMean, etc.).
Enclosed is a simplified (no vtkImageTracerWidget required) .tcl
script that demonstrates the problem with the latest vtk cvs checkout
(a .cxx version is also available). Not being overly familiar with the mechanics
of the (still evolving?) new pipeline is making the debug of this difficult.
Any help would be greatly appreciated as I would like to prepare to adapt
my production builds and local classes to include the new vtk pipeline code.
thanks,
dean
/////////////////////////////////////////////////////////////////////////////////////////////////////
package require vtk
package require vtkinteraction
vtkVolume16Reader v16
v16 SetDataDimensions 64 64
v16 SetDataByteOrderToLittleEndian
v16 SetImageRange 1 93
v16 SetDataSpacing 3.2 3.2 1.5
v16 SetFilePrefix "$VTK_DATA_ROOT/Data/headsq/quarter"
v16 ReleaseDataFlagOn
v16 SetDataMask 0x7fff
vtkExtractVOI extract
extract SetVOI 31 31 0 63 0 92
extract SetSampleRate 1 1 1
extract SetInput [v16 GetOutput]
extract ReleaseDataFlagOff
extract Update
set range [[extract GetOutput] GetScalarRange]
set min [lindex $range 0]
set max [lindex $range 1]
set diff [expr $max - $min]
set avg [expr 0.5*($max + $min)]
set bounds [[extract GetOutput] GetBounds]
vtkPoints points
points SetNumberOfPoints 5
set x [lindex $bounds 0]
set y0 [expr 0.25*[lindex $bounds 3]]
set y1 [expr 0.75*[lindex $bounds 3]]
set z0 [expr 0.25*[lindex $bounds 5]]
set z1 [expr 0.75*[lindex $bounds 5]]
points SetPoint 0 $x $y0 $z0
points SetPoint 1 $x $y1 $z0
points SetPoint 2 $x $y1 $z1
points SetPoint 3 $x $y0 $z1
points SetPoint 4 $x $y0 $z0
vtkCellArray cells
cells InsertNextCell 5
for {set i 0} {$i < 5} {incr i} {
cells InsertCellPoint $i
}
vtkPolyData region
region SetPoints points
region SetLines cells
vtkPolyDataMapper regionMapper
regionMapper SetInput region
vtkActor regionActor
regionActor SetMapper regionMapper
[regionActor GetProperty ] SetColor 1 0 0
vtkLinearExtrusionFilter extrude
extrude SetScaleFactor 1
extrude SetExtrusionTypeToNormalExtrusion
extrude SetVector 1 0 0
extrude SetInput region
vtkPolyDataToImageStencil dataToStencil
dataToStencil SetInput [extrude GetOutput]
vtkImageStencil stencil
stencil SetInput [extract GetOutput]
stencil SetStencil [dataToStencil GetOutput]
stencil ReverseStencilOff
stencil SetBackgroundValue $min
vtkImageMapToWindowLevelColors imageMapper
imageMapper SetOutputFormatToLuminance
imageMapper SetInput [stencil GetOutput]
imageMapper SetLevel $avg
imageMapper SetWindow $diff
vtkImageActor imageActor
imageActor SetInput [imageMapper GetOutput]
imageActor SetDisplayExtent 31 31 0 63 0 92
imageActor InterpolateOff
vtkImageAccumulate accum
accum SetInput [extract GetOutput]
accum ReverseStencilOff
accum SetStencil [stencil GetStencil]
accum SetComponentSpacing 1 0 0
accum SetComponentExtent 0 $diff 0 0 0 0
accum SetComponentOrigin $min 0 0
accum ReleaseDataFlagOff
accum Update
set aN [accum GetVoxelCount]
set amin [accum GetMin]
set amax [accum GetMax]
set amean [accum GetMean]
set astd [accum GetStandardDeviation]
set atext {}
append atext "N: "
append atext [string toupper $aN]
append atext ", \["
append atext [string toupper [lindex $amin 0] ]
append atext " -> "
append atext [string toupper [lindex $amax 0] ]
append atext "\] "
append atext [string toupper [lindex $amean 0] ]
append atext " +- "
append atext [string toupper [lindex $astd 0] ]
append atext " HU"
vtkTextActor textActor
textActor ScaledTextOff
textActor SetInput $atext
[textActor GetPositionCoordinate] SetCoordinateSystemToNormalizedDisplay
[textActor GetPositionCoordinate] SetValue 0.01 0.99
set tprop [textActor GetTextProperty]
$tprop SetFontSize 16
$tprop SetFontFamilyToArial
$tprop BoldOff
$tprop ItalicOff
$tprop ShadowOff
$tprop SetLineSpacing 0.9
$tprop SetJustificationToLeft
$tprop SetVerticalJustificationToTop
$tprop SetColor 1 1 0
vtkRenderer ren
ren SetBackground 0.4 0.4 0.5
vtkRenderWindow renWin
renWin AddRenderer ren
renWin SetSize 400 400
vtkInteractorStyleImage interactor
vtkRenderWindowInteractor iren
iren SetInteractorStyle interactor
iren SetRenderWindow renWin
ren AddProp imageActor
ren AddProp regionActor
ren AddProp textActor
iren AddObserver UserEvent {wm deiconify .vtkInteract}
renWin Render
set cam [ren GetActiveCamera]
$cam SetViewUp 0 1 0
$cam Azimuth 270
$cam Roll 270
$cam Dolly 1.7
ren ResetCameraClippingRange
renWin Render
# Prevent the tk window from showing up then start the event loop.
wm withdraw .
More information about the vtk-developers
mailing list