[vtkusers] vtkResliceImageViewer::SetInputData() slow when executed after vtkDICOMImageReader::Update()

ochampao ochampao at hotmail.com
Mon Feb 12 11:45:45 EST 2018


Hi Sankhesh,

I have created a minimal example with a single instance of
vtkResliceImageViewer and without Qt that reproduces the behaviour I
observe. See the code below. You may also download the dataset I have used
from <https://goo.gl/PKKrA6>.

In my code below, I have put in the comments next to each potential position
of calling Update(), how much time SetInputData() takes to complete.

Ideally, I would like to have the call to Update() in position (1). This
will allow me to separate the volume reading part into a separate function
that returns a smart pointer to the loaded vtkImageData object.

Thanks for your help,
P.

=======================

#include "vtkDICOMImageReader.h"
#include "vtkImageData.h"
#include "vtkInteractorStyleImage.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkResliceImageViewer.h"
#include "vtkSmartPointer.h"

int main(int argc, char** argv) 
{
    vtkNew<vtkDICOMImageReader> reader;
    vtkNew<vtkResliceImageViewer> resliceImageViewer;
    vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
    vtkNew<vtkInteractorStyleImage> style;
    vtkNew<vtkRenderWindow> renderWindow;
    vtkNew<vtkRenderer> renderer;
    vtkSmartPointer<vtkImageData> data;

    renderWindow->AddRenderer(renderer);
    renderer->SetBackground(0.0, 0.0, 0.0);
    renderWindowInteractor->SetInteractorStyle(style);

    reader->SetDirectoryName("path/to/dicom/series");
    //reader->Update();  // --> (1) SetInputData() takes ~18 seconds
    data = reader->GetOutput();
    //reader->Update();  // --> (2) SetInputData() takes ~18 seconds
	
    resliceImageViewer->SetInputData(data);
    reader->Update();  // --> (3) SetInputData() takes less than 1 seconds
    resliceImageViewer->SetRenderWindow(renderWindow);
    resliceImageViewer->SetupInteractor(renderWindowInteractor);
    resliceImageViewer->SetResliceModeToAxisAligned();
    resliceImageViewer->SetSlice(50);
    resliceImageViewer->SetColorLevel(-27);
    resliceImageViewer->SetColorWindow(1358);
    
    renderWindowInteractor->Start();

    return 0;
}

=======================



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list