[vtkusers] How to save the stenciled images?

Cory Quammen cquammen at cs.unc.edu
Tue May 20 09:39:30 EDT 2008


Hi Mark,

It sounds like you are having trouble showing your chosen image
component in the vtkImageViewer2. You might try something like this:

vtkImageViewer *viewer = ...;
vtkImageMapToWindowLevelColors *windowLevelMap = viewer->GetWindowLevel();
// X below is an index 0 through the number of components you stuffed
into your image
windowLevelMap->SetActiveComponent(X);

Hope that helps,
Cory

On Mon, May 19, 2008 at 8:10 AM, Mark Jefferson <mark.jefferson at qq.com> wrote:
> 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
>
> _______________________________________________
> 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
>
>



-- 
Cory Quammen
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen



More information about the vtkusers mailing list