<div dir="ltr">Can you send us a small sample output dataset? I am not sure about the values you are setting here unless I see the data. <div><br></div><div>- Aashish</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sun, Aug 31, 2014 at 9:05 AM, Yuetian Liu <span dir="ltr"><<a href="mailto:yuetian926@163.com" target="_blank">yuetian926@163.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial">Hi vtkusers,<br><div><br></div><div style="line-height:1.7">I want to blend the two volumes by vtkImageBlend. And I use <span style="line-height:1.7">vtkMetaImageReader to read two volumes(CT and MR)</span></div>
<div style="line-height:1.7"><span style="line-height:1.7"><br></span></div><div style="line-height:1.7"><span style="line-height:1.7">Then I use the vtkImageBlend to blend two volumes. And then I use the Ray Casting Algorithm to render the two volumes</span></div>
<div style="line-height:1.7"><span style="line-height:1.7"><br></span></div><div style="line-height:1.7">after blending. But the result has one color. And it is not the result that I want. My hoping result is that the CT volume is</div>
<div style="line-height:1.7"><br></div><div style="line-height:1.7">red and the MR volume was blue.</div><div style="line-height:1.7"><br></div><div style="line-height:1.7">How can I solve it. Please help me. And my code is attached.</div>
<div style="line-height:1.7"><br></div><div style="line-height:1.7">Thank you very much!</div><div style="line-height:1.7"><br></div><div style="line-height:1.7">Bset </div><div style="line-height:1.7">Yuetian</div><div style="line-height:1.7">
<br></div><div><div>#include <vtkRenderWindow.h></div><div>#include <vtkRenderWindowInteractor.h></div><div>#include <vtkRenderer.h></div><div>#include <vtkImageData.h></div><div>#include <vtkSmartPointer.h></div>
<div>#include <vtkImageBlend.h></div><div>#include "vtkMetaImageReader.h"</div><div>#include <string></div><div>#include "vtkPiecewiseFunction.h"</div><div>#include "vtkColorTransferFunction.h"</div>
<div>#include "vtkVolumeProperty.h"</div><div>#include "vtkVolumeRayCastCompositeFunction.h"</div><div>#include "vtkVolumeRayCastMapper.h"</div><div>#include "vtkVolume.h"</div><div>
#include "vtkImageCast.h"</div><div>#include <vtkLookupTable.h></div><div><br></div><div>int main ( int argc, char* argv[] )</div><div>{</div><div>  std::string input1Filename = argv[1];</div><div>  std::string input2Filename = argv[2];</div>
<div> </div><div>  vtkSmartPointer<vtkMetaImageReader>Reader1 =</div><div>    vtkSmartPointer<vtkMetaImageReader>::New();</div><div>Reader1->SetFileName ( input1Filename.c_str() );</div><div> </div><div>  vtkSmartPointer<vtkMetaImageReader> jReader2 =</div>
<div>    vtkSmartPointer<vtkMetaImageReader>::New();</div><div>Reader2->SetFileName ( input2Filename.c_str() );</div><div>  vtkSmartPointer<vtkImageBlend> imgBlender = </div><div><span style="white-space:pre-wrap">     </span>  vtkSmartPointer<vtkImageBlend>::New();</div>
<div>  imgBlender->SetOpacity( 0, 0.2 );</div><div>  imgBlender->SetOpacity( 1, 0.6 );</div><div>  imgBlender->AddInputConnection( Reader1->GetOutputPort() );</div><div>  imgBlender->AddInputConnection( Reader2->GetOutputPort() );</div>
<div><br></div><div> <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7"> vtkImageCast> readerImageCast = </span> </div><div><span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7"> vtkImageCast></span><span style="line-height:1.7">::New();</span></div>
<div>  readerImageCast->SetInputConnection(imgBlender->GetOutputPort());</div><div>  readerImageCast->SetOutputScalarTypeToUnsignedShort ();</div><div>  readerImageCast->ClampOverflowOn();</div><div><br></div>
<div> <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7"> vtkPiecewiseFunction> opacityTransferFunction =</span></div><div><span style="line-height:1.7"> </span> <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7"> vtkPiecewiseFunction></span><span style="line-height:1.7">::New();</span></div>
<div>  opacityTransferFunction->AddPoint(20, 0.0);</div><div>  opacityTransferFunction->AddPoint(255, 0.8);</div><div> <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7"> vtkColorTransferFunction > colorTransferFunction = </span> </div>
<div><span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7"> vtkColorTransferFunction > </span><span style="line-height:1.7">::New();</span></div><div>  colorTransferFunction->AddRGBPoint(0,0.9,0.7,0.5);</div>
<div>  colorTransferFunction->AddRGBPoint(15,1,0.7,0.6);</div><div>  colorTransferFunction->AddRGBPoint(255,1,0,0);</div><div>  <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7">vtkVolumeProperty> volumeProperty = </span></div>
<div>  <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7">vtkVolumeProperty></span><span style="line-height:1.7">::New();</span></div><div>  volumeProperty->SetColor(colorTransferFunction);</div>
<div>  volumeProperty->SetScalarOpacity(opacityTransferFunction);</div><div>  volumeProperty->ShadeOn();</div><div>  volumeProperty->SetInterpolationTypeToLinear();</div><div>  volumeProperty->SetSpecular(0.1);</div>
<div>  volumeProperty->SetSpecularPower(8); </div><div>  volumeProperty->SetScalarOpacityUnitDistance(0.8919);</div><div>  <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7">vtkVolumeRayCastCompositeFunction> compositeFunction =</span></div>
<div><span style="line-height:1.7"> </span>  <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7">vtkVolumeRayCastCompositeFunction></span><span style="line-height:1.7">::New();</span></div>
<div> <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7"> vtkVolumeRayCastMapper> volumeMapper =</span></div><div><span style="line-height:1.7"> </span> <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7"> vtkVolumeRayCastMapper> </span><span style="line-height:1.7">::New(); </span></div>
<div>  volumeMapper->SetVolumeRayCastFunction(compositeFunction); </div><div>  volumeMapper->SetInputConnection(readerImageCast->GetOutputPort());</div><div>  volumeMapper->SetNumberOfThreads(3);</div><div>  <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7">vtkVolume> volume =</span></div>
<div><span style="line-height:1.7"> </span>  <span style="line-height:1.7">vtkSmartPointer<</span><span style="line-height:1.7">vtkVolume></span><span style="line-height:1.7">::New();</span></div><div>  volume->SetMapper(volumeMapper);</div>
<div>  volume->SetProperty(volumeProperty);</div><div><br></div><div>  vtkSmartPointer<vtkRenderer> renderer =</div><div><span style="white-space:pre-wrap"> </span>  vtkSmartPointer<vtkRenderer>::New();</div>
<div>  vtkSmartPointer<vtkRenderWindow> renderWindow =</div><div><span style="white-space:pre-wrap">   </span>  vtkSmartPointer<vtkRenderWindow>::New();</div><div>  renderWindow->AddRenderer(renderer);</div><div>
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =</div><div><span style="white-space:pre-wrap">  </span>  vtkSmartPointer<vtkRenderWindowInteractor>::New();</div><div>  renderWindowInteractor->SetRenderWindow(renderWindow);</div>
<div>  renderer->AddVolume(volume);</div><div>  renderWindow->Render();</div><div>  renderWindowInteractor->Start();</div><div>  return EXIT_SUCCESS;</div><div>}</div></div><div style="line-height:1.7"><br></div>
<div style="line-height:1.7"><br></div><div style="line-height:1.7"><br></div></div><br><br><span title="neteasefooter"><span></span></span></div></div><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://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><font face="trebuchet ms, sans-serif"><i>| Aashish Chaudhary <br>| Technical Leader         <br>| Kitware Inc.            <br></i></font><div>
<i><font face="trebuchet ms, sans-serif">| </font><a href="http://www.kitware.com/company/team/chaudhary.html" target="_blank">http://www.kitware.com/company/team/chaudhary.html</a></i></div></div>
</div>