vtkImageBlend is intended for this scenario. You could pass your input image and the overlay segmentation. Blend them and assign approriate colors through the blender.<br><br><div class="gmail_quote">On Fri, Mar 27, 2009 at 1:49 PM, Charlotte Curtis <span dir="ltr"><<a href="mailto:c.f.curtis@gmail.com">c.f.curtis@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Just a follow-up in case anyone else has this problem: it seems that<br>
vtkActor2D cannot layer with transparency. Switching to a<br>
vtkImageActor solved the problem, although introducing a few others<br>
(like requiring the data to be unsigned char, meaning some of the<br>
intensity data of the image must be discarded).<br>
<br>
Charlotte<br>
<br>
On Tue, Mar 24, 2009 at 1:14 PM, Charlotte Curtis <<a href="mailto:c.f.curtis@gmail.com">c.f.curtis@gmail.com</a>> wrote:<br>
><br>
> Hi Jeff, thanks for the reply.<br>
><br>
> I'm not sure what you mean by exactly the same location - it's true<br>
> that they are at the same xy location, but they are on different<br>
> layers, or at least that's what I'd like them to be doing. I tried<br>
> changing the Z location with Mapper->SetZSlice, but this just resulted<br>
> in the entire segmentation mask becoming opaque (including the values<br>
> that are mapped through the LUT to an alpha of zero).<br>
><br>
> I tried setting the opacity of both images to 0.5 as you suggested<br>
> (using actor->GetProperty()->SetOpacity()), and this didn't seem to<br>
> change anything. Even setting the opacity to zero results in opaque<br>
> images, although if I set the alpha of my LUT values to zero the image<br>
> does indeed disappear.<br>
><br>
> If I print various values to std::cout, everything seems to be in<br>
> order - for example, overlayRenderer->Transparent() returns 1,<br>
> overlayActor->GetProperty()->GetOpacity() returns whatever I set it to<br>
> (0.5), etc. I thought perhaps there was something wrong with my<br>
> system graphics/opengl setup, but if I build and run the "medical 3"<br>
> example I do get a transparent volume. Reading through the code in<br>
> that file, the only difference I could see was that it uses a single<br>
> renderer with multiple actors so I tried that as well, but nothing<br>
> seemed to change.<br>
><br>
> Thanks again for the help,<br>
><br>
> Charlotte<br>
><br>
> On Tue, Mar 24, 2009 at 8:09 AM, Jeff Baumes <<a href="mailto:jeff.baumes@kitware.com">jeff.baumes@kitware.com</a>> wrote:<br>
> > It looks like the images are displayed at exactly the same location? I<br>
> > believe the image mapper maps a texture to a quad, so perhaps you have<br>
> > conflicting geometry. The other thing I would try is to set the<br>
> > opacity of both images to less than 1.0 (like 0.9 and 0.5), so that<br>
> > they are both rendered in the same render pass. VTK first renders any<br>
> > opaque geometry, then renders translucent geometry, so that may be why<br>
> > it gets obscured.<br>
> ><br>
> > Jeff<br>
> ><br>
> > On Mon, Mar 23, 2009 at 9:38 PM, Charlotte Curtis <<a href="mailto:c.f.curtis@gmail.com">c.f.curtis@gmail.com</a>> wrote:<br>
> >> Hi all,<br>
> >><br>
> >> I've got a couple of images displayed on top of each other, one a 2D<br>
> >> medical image, and the other a binary segmentation mask. They each<br>
> >> have their own image actors and renderers, and I created a lookup<br>
> >> table for the segmentation mask in the hopes that it would let me<br>
> >> render the mask as semi-transparent colours. Right now I've got two<br>
> >> values in the LUT (corresponding to the image values of 0 and 1), and<br>
> >> I can change the colours, but the transparency is binary - if I set<br>
> >> the alpha value to 0, it doesn't display, but if it's anything else<br>
> >> (even 0.001) then the mask is completely opaque.<br>
> >><br>
> >> I've also tried changing the opacity of the actor<br>
> >> (actor->GetProperty->SetOpacity()), but this doesn't seem to do<br>
> >> anything, although when I print out the value of the actor's opacity<br>
> >> it thinks that it is set correctly.<br>
> >><br>
> >> Perhaps my window/levels are wrong? I'm kind of at a loss. Apologies<br>
> >> if this has been asked (seems like a common problem, but I couldn't<br>
> >> find a solution so far). Thanks,<br>
> >><br>
> >> Charlotte<br>
> >><br>
> >> // Create the common components for the image viewer<br>
> >> vtkRenderWindow* renWin = vtkRenderWindow::New();<br>
> >> vtkRenderWindowInteractor* interactor = renWin->MakeRenderWindowInteractor();<br>
> >> interactor->SetRenderWindow( renWin );<br>
> >><br>
> >> // Create the components for the image display<br>
> >> vtkRenderer* imageRenderer = vtkRenderer::New();<br>
> >> vtkActor2D* imageActor = vtkActor2D::New();<br>
> >> vtkImageMapper* imageMapper = vtkImageMapper::New();<br>
> >><br>
> >> // Set the values and connect them together<br>
> >> imageMapper->SetColorWindow( 1024 );<br>
> >> imageMapper->SetColorLevel( 512 );<br>
> >> imageMapper->SetInput( connector->GetOutput() );<br>
> >> imageActor->SetMapper( imageMapper );<br>
> >> imageRenderer->AddActor( imageActor );<br>
> >><br>
> >> // Create the components for the mask layer<br>
> >> vtkRenderer* overlayRenderer = vtkRenderer::New();<br>
> >> vtkActor2D* overlayActor = vtkActor2D::New();<br>
> >> vtkImageMapper* overlayMapper = vtkImageMapper::New();<br>
> >> vtkLookupTable* overlayLUT = vtkLookupTable::New();<br>
> >> vtkImageMapToColors* colourMapper = vtkImageMapToColors::New();<br>
> >><br>
> >> /************************* This is the part that's not behaving<br>
> >> ********************************/<br>
> >> // set properties of the various overlay components<br>
> >> //overlayActor->GetProperty()->SetOpacity( 0.5 ); this doesn't seem to<br>
> >> do anything<br>
> >> double outsideColour[4] = {1.0, 0, 0, 0.5}; // This one shows up as<br>
> >> completely opaque red.<br>
> >> double insideColour[4] = {1.0, 1.0, 1.0, 0}; // This one doesn't show,<br>
> >> which is correct.<br>
> >> overlayLUT->SetNumberOfTableValues(2);<br>
> >> overlayLUT->SetTableRange(0, 1);<br>
> >> overlayLUT->SetTableValue( 0, outsideColour );<br>
> >> overlayLUT->SetTableValue( 1, insideColour );<br>
> >> overlayLUT->Build();<br>
> >> overlayMapper->SetColorLevel( 0.5 );<br>
> >> overlayMapper->SetColorWindow( 0.5 );<br>
> >><br>
> >> // Connect the overlay stuff together<br>
> >> colourMapper->SetLookupTable( overlayLUT );<br>
> >> colourMapper->SetInput( binConnector->GetOutput() );<br>
> >> overlayMapper->SetInput( colourMapper->GetOutput() );<br>
> >> overlayActor->SetMapper( overlayMapper );<br>
> >> overlayRenderer->AddActor( overlayActor );<br>
> >><br>
> >> // Connect everything together<br>
> >> renWin->SetSize( size[0], size[1] );<br>
> >> renWin->SetNumberOfLayers( 2 );<br>
> >> renWin->AddRenderer( imageRenderer );<br>
> >> renWin->AddRenderer( overlayRenderer );<br>
> >> imageRenderer->SetLayer( 0 );<br>
> >> overlayRenderer->SetLayer( 1 );<br>
> >><br>
> >> // Look at the pretty picture!<br>
> >> renWin->Render();<br>
> >> interactor->Start();<br>
> >> _______________________________________________<br>
> >> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
> >><br>
> >> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
> >><br>
> >> Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
> >><br>
> >> Follow this link to subscribe/unsubscribe:<br>
> >> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
> >><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > Jeff Baumes, Ph.D.<br>
> > R&D Engineer, Kitware Inc.<br>
> > (518) 371-3971 x132<br>
> > <a href="mailto:jeff.baumes@kitware.com">jeff.baumes@kitware.com</a><br>
> ><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Karthik Krishnan<br>R&D Engineer,<br>Kitware Inc.<br>Ph: 518 881 4919<br>Fax: 518 371 4573<br>