VTK :图像处理_窗口分割和图像融合 报错 Input for connection on index 0 input port index 1 for algorithm vtkImageBlen

报错vtkCompositeDataPipeline (004A4880): Input for connection on index 0 input port index 1 for algorithm vtkImageBlend(004A1958) is of type vtkImageData, but a vtkImageStencilData is required.

只需将原程序中

imageBlend->SetInput(0,reader->GetOutput());
imageBlend->SetInput(1,imageSource->GetOutput());

改为

imageBlend->AddInputData(reader->GetOutput());
imageBlend->AddInputData(imageSource->GetOutput());

即可。

----------------------上面办法测试了,好像不行,虽然不报错了,但是图片没有融合进去--------

 

/*blend->SetInputData(reader->GetOutput());
    blend->SetInputData(source->GetOutput());*/
    /**
    
vtkCompositeDataPipeline (004A4880): Input for connection on index 0 input port index 1 for algorithm vtkImageBlend(004A1958) is of type vtkImageData, but a vtkImageStencilData is required.
    当vtkImageBlend的inputData大于2个对象时,需要通过AddInputData来设置InputData,demo如下:
 
    **/


    blend->AddInputData(reader->GetOutput());
    blend->AddInputData(source->GetOutput());
    blend->SetOpacity(0, 0.4);
    blend->SetOpacity(1, 0.6);

改成 AddInputData 后执行成功;

你可能感兴趣的:(VTK,&,ITK,c++,人工智能)