[vtkusers] vtkConnectivityFilter output

Mark Wyszomierski markww at gmail.com
Mon Apr 18 10:26:15 EDT 2005


Hello,

I have a vtkImageData instance which holds image data read in from a
stack of images. When I click a point while viewing the image data, I
get the pixel's scalar value, and its point ID within the image data
instance.

Given these pieces of information, I would like to use the
connectivity filter to extract a list of neighboring pixels which are
connected and share a similar scalar value. Is this how the
connectivity filter works?

This is my setup, which may be a little pseudo-codish:

// Get the coordinates of the pixel clicked on.
double *MappedPixelCoordinates =
Picker->Pick(GetInteractor()->GetEventPosition()[0],
GetInteractor()->GetEventPosition()[1], nSliceNumber);

// Get the scalar value of the pixel clicked on. (for arguments sake).
int nScalarValueOfClickedPixel = 50; 

// Setup the connectivity filter.
vtkConnectivityFilter *Connectivity = vtkConnectivityFilter::New();

// Accept connected pixels which have a scalar value +/-10 ???
Connectivity->SetScalarRange(nScalarValueOfClickedPixel - 10,
mnScalarValueOfClickedPixel + 10);

// Is this the 'start' pixel?
Connectivity->SetClosestPoint(MappedPixelCoordinates);

// Get the output?
Connectivity->GetOutput();

Is the filter setup correctly? If it is, How do I store the output,
and in what form will it be in?

Thanks for any pointers,
Mark



More information about the vtkusers mailing list