[vtkusers] vtkImageIslandRemoval2D & vtkImageDataStreamer
Rolf Mueller
rolf.mueller at gmail.com
Fri Apr 7 04:43:52 EDT 2006
Dear VTK-Users,
I am trying to use vtkImageIslandRemoval2D in a pipeline with
streaming image data. An example code snippet of what I am trying to
do is given below. If I do not call the Update-method of
vtkImageDataStreamer, I get a segmentation fault (in
vtkImageDataCastExecute ultimately called by vtkPNGWriter::Write() ).
If I do call it, I get a set of output images, but they are mostly
black. This happens for different numbers of stream divisions. The
source code for vtkImageIslandRemoval2D includes the header
vtkStreamingDemandDrivenPipeline.h, but I am not sure if that means
that it is supposed to work with a streaming pipeline. Am I doing
something wrong or is there something wrong with those classes? - I am
using today's cvs version of vtk and g++ (GCC) 4.0.3 (Debian 4.0.3-1).
Thank you very much for any insights you may wish to share.
Rolf
vtkImageData *idata = vtkImageData::New();
idata->SetScalarTypeToUnsignedChar();
idata->SetExtent(0, nx-1, 0, ny-1, 0, nz-1);
unsigned char *pt = (unsigned char*)(idata->GetScalarPointer());
for (k=0; k<(nx*ny*nz); k++)
*(pt++)=255;
vtkImageIslandRemoval2D *ir = vtkImageIslandRemoval2D::New();
ir->SetInput(idata);
ir->SetAreaThreshold(2);
ir->SquareNeighborhoodOn();
ir->SetIslandValue(0);
ir->SetReplaceValue(255);
vtkImageDataStreamer *ids = vtkImageDataStreamer::New();
ids->SetInputConnection(ir->GetOutputPort());
ids->SetNumberOfStreamDivisions(nblk);
ids->UpdateInformation();
ids->GetExtentTranslator()->SetSplitModeToBlock();
ids->Update();
vtkPNGWriter *wrt = vtkPNGWriter::New();
wrt->SetInputConnection(ids->GetOutputPort());
wrt->SetFileDimensionality(2);
wrt->SetFilePrefix("islndstrmtst");
wrt->SetFilePattern("%s_%02u.png");
wrt->Write();
More information about the vtkusers
mailing list