[vtkusers] vtkResliceImageViewer::SetInputData() slow when executed after vtkDICOMImageReader::Update()
ochampao
ochampao at hotmail.com
Fri Feb 9 11:22:34 EST 2018
Hello vtkusers!
I am experimenting with a simple dicom viewer similar to the FourPaneViewer
example (see [1] for link). But I am observing a behaviour which I can't
explain. In particular, when I place the
vtkResliceImageViewer::SetInputData()
calls before calling the vtkDICOMImageReader::Update(), the dataset is
loaded extremely fast (approximately 2 seconds). However when
vtkResliceImageViewer::SetInputData() calls are placed after
vtkDICOMImageReader::Update(), then loading the dataset requires
significantly more time to load (approximately 22 seconds). See minimal
code example below.
Why is the code slower when executed after the Update() call and how can
this be avoided?
Is it wrong to place the SetInputData() call after Update()? If yes, how can
the vtkImageData object be passed to SetInputData() so that it is still
fast?
For the slower case, when stepping through the code with the debugger, I can
see that the call to Update() is still fast but the debugger spends most of
its time at SetInputData().
Eventually, what I'd like to do is group the code that reads the dicom into
a separate function that returns a vtkImageData reference to the pipeline.
But from this experiment it seems to work very slow.
Thanks,
Panos.
=======
Here is a minimal example of my code to demonstrate the two situation
(commented is the slow case):
void addImage(const char* filename)
{
vtkSmartPointer< vtkDICOMImageReader > reader =
vtkSmartPointer< vtkDICOMImageReader >::New();
reader->SetDirectoryName(filename);
vtkSmartPointer<vtkImageData> data =
vtkSmartPointer<vtkImageData>::New();
data = reader->GetOutput();
//---------------------------------------
// SetInputData() works very fast if here
resliceImageViewer1->SetInputData(data);
resliceImageViewer2->SetInputData(data);
resliceImageViewer3->SetInputData(data);
// ---------------------------------------
reader->Update();
//---------------------------------------
// SetInputData() works very slow if here
//
//resliceImageViewer1->SetInputData(data);
//resliceImageViewer2->SetInputData(data);
//resliceImageViewer2->SetInputData(data);
//---------------------------------------
/*
code to setup widgets (orientation, slice#, window/level color)
*/
resliceImageViewer1->Render();
resliceImageViewer2->Render();
resliceImageViewer3->Render();
}
========
References:
[1]:
https://github.com/Kitware/VTK/tree/master/Examples/GUI/Qt/FourPaneViewer
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list