How to get a pointer of a VTK image to use in C.

Dear All,

    vtkSmartPointer<vtkImageConnectivityFilter> connectivity;
    connectivity->SetInputData(image4);
    connectivity->SetScalarRange(255, 255);
    connectivity->SetSeedData(seedData2);
    connectivity->Update();

I want to have access to the connectivity image that is in VTK format. How I get the pointer to use the data (image) in C?
connectivity->GetOutput()->GetPointData()->GetScalars(), do not works. Seems not to be pointer I want.

Thanks,

Luís Gonçalves

Hello Luis,

u can do the following:

    vtkSmartPointer<vtkImageConnectivityFilter> connectivity;
    connectivity->SetInputData(image4);
    connectivity->SetScalarRange(255, 255);
    connectivity->SetSeedData(seedData2);
    connectivity->Update();
    vtkSmartPointer<vtkImageData> result = connectivity->GetOutput();
    void* ptr = result ->GetScalarPointer();

U can then use it in c but make sure that vtkSmartPointer does not get freed. Otherwise your pointer won’t be valid anymore. I usually do a copy of the data before using it.

Thanks.