[vtkusers] vtkImageIslandRemoval2D & vtkImageDataStreamer

Mathieu Malaterre mathieu.malaterre at kitware.com
Fri Apr 7 18:25:11 EDT 2006


Rolf,

	Can you open a bug report for that, at :

http://vtk.org/Bug

	Please include this small c++ code in your report.

Thanks
Mathieu

Rolf Mueller wrote:
> 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();
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 




More information about the vtkusers mailing list