# Problem in SetInputConnection.

**URL:** https://discourse.vtk.org/t/problem-in-setinputconnection/6290
**Category:** Support
**Created:** [August 3, 2021, 7:20pm UTC](https://discourse.vtk.org/t/problem-in-setinputconnection/6290 "2021-08-03T19:20:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.vtk.org/user_avatar/discourse.vtk.org/luis_carlos_carneiro/32/1360_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.vtk.org/u/Luis_Carlos_Carneiro)
#### Post date: [August 3, 2021, 7:20pm UTC](https://discourse.vtk.org/t/problem-in-setinputconnection/6290/1 "2021-08-03T19:20:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [August 3, 2021, 11:10pm UTC](https://discourse.vtk.org/t/problem-in-setinputconnection/6290/2 "2021-08-03T23:10:18Z")

</div>

If you aim to use VTK, it might be worth reading [the free book available in PDF](https://vtk.org/vtk-textbook/) 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.

---

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.vtk.org/user_avatar/discourse.vtk.org/luis_carlos_carneiro/32/1360_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.vtk.org/u/Luis_Carlos_Carneiro)
#### Post date: [August 3, 2021, 11:25pm UTC](https://discourse.vtk.org/t/problem-in-setinputconnection/6290/3 "2021-08-03T23:25:06Z")

</div>

Thanks.
