This example may help you: <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/Transparency">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/Transparency</a><br><br><div class="gmail_quote">On Mon, Feb 21, 2011 at 11:47 PM, kigras <span dir="ltr">&lt;<a href="mailto:kigras@gmail.com">kigras@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
 Hi,<br>
I would like to visualize two images at the same time in one renderer window<br>
(CT and binary images in vtkImageViewer2). In my opinnion using vtkBlend is<br>
a good direction to follow. However, I  encounter some problems. At present,<br>
In my software I can simple visualize CT slice with all functionality<br>
provided by vtkImageViewer2, i need to preserve that functionality ie.<br>
window level adjustment. Now I have binary image (with the same size), my<br>
goal is to make transparent all black pixels and color to half transparent<br>
yellow all object pixels. However, when I use following code the results are<br>
not as I have expected.<br>
<br>
This is my code:<br>
<br>
     //read raw file<br>
<br>
    vtkImageReader *ImageReader =  vtkImageReader::New();<br>
    ImageReader-&gt;SetFileName(&quot;p1tree.raw&quot;);<br>
    ImageReader-&gt;SetDataScalarTypeToUnsignedChar();<br>
    ImageReader-&gt;SetDataByteOrder(0);<br>
    ImageReader-&gt;SetFileDimensionality(3);<br>
    ImageReader-&gt;SetDataOrigin (0.0, 0.0, 0.0);<br>
    ImageReader-&gt;SetDataSpacing(1.0 ,1.0, 1.0);<br>
    ImageReader-&gt;SetDataExtent( 0,431, 0, 270, 0, 444);<br>
    ImageReader-&gt;SetNumberOfScalarComponents(1);<br>
<br>
    //input=ImageReader-&gt;GetOutput();<br>
    ImageReader-&gt;Update();<br>
    vtkImageReader *ImageReader1 =  vtkImageReader::New();<br>
    ImageReader1-&gt;SetFileName(&quot;p1.raw&quot;);<br>
    ImageReader1-&gt;SetDataScalarTypeToShort();<br>
    ImageReader1-&gt;SetDataByteOrder(1);<br>
    ImageReader1-&gt;SetFileDimensionality(3);<br>
    ImageReader1-&gt;SetDataOrigin (0.0, 0.0, 0.0);<br>
    ImageReader1-&gt;SetDataSpacing(1.0 ,1.0, 1.0);<br>
    ImageReader1-&gt;SetDataExtent( 0,431, 0, 270, 0, 444);<br>
    ImageReader1-&gt;SetNumberOfScalarComponents(1);<br>
    ImageReader1-&gt;Update();<br>
<br>
    //color<br>
<br>
    vtkSmartPointer&lt;vtkLookupTable&gt; FirstColorMap =<br>
      vtkSmartPointer&lt;vtkLookupTable&gt;::New();<br>
<br>
//binary<br>
        FirstColorMap-&gt;SetTableValue(0, 0.2000, 0.6300, 0.7900, 1);<br>
        FirstColorMap-&gt;Build();<br>
<br>
//CT<br>
   vtkSmartPointer&lt;vtkLookupTable&gt; ColorMap =<br>
     vtkSmartPointer&lt;vtkLookupTable&gt;::New(); // hot color map]<br>
<br>
       ColorMap-&gt;SetTableValue(0, 0.8900, 0.8100, 0.3400, 1);<br>
       ColorMap-&gt;Build();<br>
<br>
      vtkImageCast *cast = vtkImageCast::New();<br>
<br>
      cast-&gt;SetInput(ImageReader-&gt;GetOutputDataObject(0));<br>
      cast-&gt;SetOutputScalarTypeToShort();<br>
      cast-&gt;ClampOverflowOn();<br>
      cast-&gt;Print(std::cout);<br>
<br>
<br>
      vtkSmartPointer&lt;vtkImageMapToColors&gt; ColorMapper =<br>
          vtkSmartPointer&lt;vtkImageMapToColors&gt;::New();<br>
      ColorMapper-&gt;SetInput( cast-&gt;GetOutput() );<br>
      ColorMapper-&gt;SetLookupTable( FirstColorMap );<br>
<br>
      vtkSmartPointer&lt;vtkImageMapToColors&gt; ColorMapper1 =<br>
          vtkSmartPointer&lt;vtkImageMapToColors&gt;::New();<br>
      ColorMapper1-&gt;SetInput( ImageReader1-&gt;GetOutput() );<br>
      ColorMapper1-&gt;SetLookupTable( ColorMap );<br>
<br>
<br>
    // Combine the images (blend takes multiple connections on the 0th input<br>
port)<br>
    vtkSmartPointer&lt;vtkImageBlend&gt; blend =<br>
      vtkSmartPointer&lt;vtkImageBlend&gt;::New();<br>
<br>
    //blend-&gt;AddInputConnection(0,cast-&gt;GetOutputPort());<br>
    //blend-&gt;AddInputConnection(0,ImageReader1-&gt;GetOutputPort());<br>
<br>
<br>
    blend-&gt;AddInputConnection(0,ColorMapper-&gt;GetOutputPort());<br>
    blend-&gt;AddInputConnection(0,ColorMapper1-&gt;GetOutputPort());<br>
<br>
    blend-&gt;SetOpacity(0,1.0);<br>
    blend-&gt;SetOpacity(1,.5);<br>
<br>
    // Display the result<br>
    vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; renderWindowInteractor =<br>
      vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();<br>
<br>
    vtkSmartPointer&lt;vtkImageViewer2&gt; imageViewer =<br>
      vtkSmartPointer&lt;vtkImageViewer2&gt;::New();<br>
    imageViewer-&gt;SetColorLevel(0);<br>
    imageViewer-&gt;SetColorWindow(255);<br>
    imageViewer-&gt;SetSliceOrientation(2);<br>
    imageViewer-&gt;SetSlice(259);<br>
<br>
    imageViewer-&gt;SetInputConnection(blend-&gt;GetOutputPort());<br>
    imageViewer-&gt;SetupInteractor(renderWindowInteractor);<br>
    imageViewer-&gt;GetRenderer()-&gt;ResetCamera();<br>
    imageViewer-&gt;SetSize( 800, 800 );<br>
    imageViewer-&gt;GetRenderer()-&gt;SetBackground(.1,.2,.3); //dark blue<br>
<br>
    vtkRenderer *ren = vtkRenderer::New();<br>
    vtkImageActor * mriActor = vtkImageActor::New();<br>
    mriActor-&gt;SetInput(blend-&gt;GetOutput());<br>
    ren-&gt;AddViewProp( mriActor );<br>
<br>
    renderWindowInteractor-&gt;Initialize();<br>
    renderWindowInteractor-&gt;Start();<br>
<br>
<br>
<br>
I attach a few pics what I want to result:<br>
<a href="http://vtk.1045678.n5.nabble.com/file/n3394758/bin.png" target="_blank">http://vtk.1045678.n5.nabble.com/file/n3394758/bin.png</a>  // binary picture<br>
<a href="http://vtk.1045678.n5.nabble.com/file/n3394758/CT.png" target="_blank">http://vtk.1045678.n5.nabble.com/file/n3394758/CT.png</a>  // CT picture<br>
<a href="http://vtk.1045678.n5.nabble.com/file/n3394758/CTandBIN.png" target="_blank">http://vtk.1045678.n5.nabble.com/file/n3394758/CTandBIN.png</a>  // combined<br>
pictures this is my goal<br>
<br>
<br>
<br>
Thanks a lot for help.<br>
<br>
Jakub Igras<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Blending-two-different-slices-of-raw-file-and-color-one-of-them-tp3394758p3394758.html" target="_blank">http://vtk.1045678.n5.nabble.com/Blending-two-different-slices-of-raw-file-and-color-one-of-them-tp3394758p3394758.html</a><br>

Sent from the VTK - Users mailing list archive at Nabble.com.<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"><div><br></div>-- <br>Jesús Spínola<br>