Problem in SetInputConnection.

Dear All,

Taking in account the code below:

    unsigned char *image3; //contains the raw image

vtkNew<vtkImageConnectivityFilter> connectivity;
    vtkSmartPointer<vtkImageData> image4 =  vtkSmartPointer<vtkImageData>::New();

    image4->SetDimensions(dim3);
    image4->SetSpacing(scale1);   
image4->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
memcpy(image4->GetScalarPointer(), image3, dim3[0]*dim3[1]*dim3[2]);
    ..........
    ..........
    ..........
    connectivity->SetInputConnection(image4->XXXXXXXXXXXX);

Can you please help me in what I have to put in “XXXXXXXXXXXXX”?

Thanks,

Luís Gonçalves

If you aim to use VTK, it might be worth reading the free book available in PDF especially the pipeline section.

Otherwise the answer is:

  1. Your image4 is a dataset not an algorithm therefore you can not use SetInputConnection
  2. To connect a dataset to an algorithm you need to use SetInputData instead.

Thanks.