0

I'm trying to display a volume slices-composed in QT5+VTK 7.0.0. However, I don't know why using vtkImageSlice+vtkImageStack only shows me one slice instead of five slices. This is the code I'm using it:

/*This function receives an ultrasound image from network.
The function is working fine if we display the 2D images,
but I want to stack a bunch of images in a volume.
The imageStack at the end always keeps one image only.*/
void WDisplay::Disp(QImage b)
{
    // qimagevtk is a vtkSmartPointer<vtkQImageToImageSource> type
    qimagevtk->SetQImage(&b);
    qimagevtk->Update();
    // imageSliceMapper is a vtkSmartPointer<vtkImageSliceMapper> type
    imageSliceMapper->SetInputData(qimagevtk->GetOutput());
    // imageSliceMapper is a vtkSmartPointer<vtkImageSlice> type
    imageSlice->SetMapper(imageSliceMapper);
    imageSlice->GetProperty()->SetOpacity(.5);

    // Stack
    // vtkSmartPointer<vtkImageStack>
    imageStack->AddImage(imageSlice);
    if(!(idx<5)) //idx initialized at zero in the constructor
    {
        // m_renderer ---> vtkRenderer
        m_renderer->AddViewProp(imageStack);
        m_renderer->Render();
        // wvtk ---> QVTKWidget
        wvtk->GetInteractor()->Render();
        idx = 0;
    }
    else
        idx++;
}

This is the output (screenshot) I got when I run the function: screenshot

Every vtk object was created in the constructor using vtkSmartPointer<vtk object type>::New(). I hope anyone can help me. Thank you.

4

1 回答 1

1

vtkImageStack 中的切片位于相同的物理位置,想想 Photoshop 中的图层。因此,您需要为每个图像切片分配层号。

看看vtkImageProperty::SetLayerNumber(int)vtkImageStack::SetActiveLayer(int)

为每个切片创建不同的查找表以映射,或更改不透明度,以便您可以看穿堆栈中的切片。

并帮助每个阅读您的代码的人并更改if(!(idx<5))if(idx>=5).

高温下,

米罗

于 2016-03-10T19:12:37.737 回答