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