VTK 图像切片到体积 (C++)

VTK Image slices to volume (C++)

我正在尝试显示在 QT5+VTK 7.0.0 中组成的卷切片。但是,我不知道为什么使用 vtkImageSlice+vtkImageStack 只显示 one 切片而不是 片。这是我正在使用的代码:

/*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++;
}

这是我 运行 函数时得到的输出(屏幕截图):

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

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

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

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

请阅读您的代码的每个人帮个忙,将 if(!(idx<5)) 更改为 if(idx>=5)

HTH,

米罗