[vtkusers] How to save the stenciled images?

Mark Jefferson mark.jefferson at qq.com
Mon May 19 08:10:06 EDT 2008


Thank you for your help, Cory, 
    but I still don't know what's wrong with it. of course I have used class vtkImageAppendComponents, however, it doesn't work, and the image that shown by using class vtkImageViewer2 is always the last one or the first one.
   could you help me to see what's wrong with my codes here:
   vtkImageAppendComponents * imageAppend = vtkImageAppendComponents::New();
   vtkImageStencil * temp1 = FinishImageStencil();
   imageAppend->AddInput(temp1->GetOutput());  
   vtkImageStencil * temp2 = FinishImageStencil();
   imageAppend->AddInput(temp2->GetOutput());
   vtkXMLImageDataWriter * writer = vtkXMLImageDataWriter::New();
   writer->SetInputConnection(imageAppend->GetOutputPort());
   writer->SetFileName("image.vti");
   writer->SetDataModeToBinary();
   writer->Update();
   writer->Write();
   vtkXMLImageDataReader * reader = vtkXMLImageDataReader::New();
   reader->SetFileName("image.vti");
   reader->Update();
   vtkImageData * xmlImageData = vtkImageData::New();
   xmlImageData->DeepCopy(reader->GetOutput());
   // display the images in image.vti using class vtkImageViewer2
   ... ...
   // FinishImageStencil() is a function returning a object of class vtkImageStencil.
   here I just save two stenciled images, at the same time, I use class vtkBMPWriter to save the stenciled images, too. but the result is : the result is not right if I use vtkXMLImageDataWriter. and I doubt there is only one image in the image.vti.
   could you help me? thank you!
   M. J.
   
  
  
 -----------------------------------------------------------------------------------------------------------------------------------------------------------
 Mark,
The closest you can probably come is to jam all the stencil images
together into one image with vtkImageAppendComponents and then save
the whole thing into a single .vti file. I don't believe you can save
more than one image in a single .vti file (someone on list correct me
if I am wrong). You might be able to exploit VTK's relatively new time
support and treat your images as though they were time-series data,
but I am not familiar enough with that to give you advice (you might
find some hints for time-series data in the documentation for
vtkXMLWriter: http://www.vtk.org/doc/nightly/html/classvtkXMLWriter.html).

Hope that helps,
Cory

-- 
Cory Quammen
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080519/c6702b2b/attachment.htm>


More information about the vtkusers mailing list