[vtkusers] [SPAM] problem of class vtkImageAppendComponents
Amy Squillacote
ahs at cfdrc.com
Wed May 21 09:41:10 EDT 2008
Hi Mark,
You can have multiple input connections on the same input port, and this
is what is expected for vtkImageAppendComponents. Try using port 0 for
both input connections. Only the first input port is used by this
filter, which explains both the warning message you're seeing and why
both components in the output are from the first input.
For filters in VTK that take multiple inputs, if the function of the
inputs is the same (as is the case here -- all the input datasets will
be appended together), then one input port with multiple connections is
used. If the function of the inputs is different (e.g., in the glyph
filter -- one input determines the position of the glyphs; another input
determines the geometry to place at those positions), then multiple
input ports are used -- one input port for each different type of input.
Thanks for posting the code snippet and the warning message; it made it
clearer what was likely going wrong.
- Amy
Mark Jefferson wrote:
> Thank you for your help, Cory,
> I have test the data output of vtkImageAppendComponents, and I write
> its output into a .vti file.
> I use VolView to test this .vti data, I find there really are two
> "different" components in the .vti data, but the component 0(default)
> and component 1 are always the same. or in other words, the two
> components are the same, and the components are all the first one,
> that is the default component.
> but from the vtk document, we could know the output's number of
> components are the summation of the two inputs' number of components,
> so the .vti data should have two components. what's more, my data is
> different, they come from the same large CT dataset, which are the
> first one and the last one.
> in my .vti data, another component is lost. and here are my codes:
> vtkImageAppendComponents * append = vtkImageAppendComponents::New();
> append->AddInputConnection(0, reader1->GetOutputPort());
> append->AddInputConnection(1, reader2->GetOutputPrort());
> append->Update();
> // wirte the append's output into a .vti file
> ... ...
> and then I get one warning, not error:
> vtkImageAppendComponents (0x02C3DC50): Attempt to connect input port
> index 1 for an algorithm with 1 input ports.
> it seems there is something wrong with input port index 1. and maybe
> this is the key why there is only one component in .vti data.
> could you tell me why? what's wrong with my codes? thank you!
> M. J.
>
> ------------------------------------------------------------------------------------------------------------------------------------------------
> 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
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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
>
--
Amy Squillacote Phone: (256) 726-4839
Computer Scientist Fax: (256) 726-4806
CFD Research Corporation Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL 35805
More information about the vtkusers
mailing list