<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 class="Apple-tab-span" style="white-space:pre">   </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 class="Apple-tab-span" style="white-space:pre">     </span>  vtkSmartPointer<vtkRenderer>::New();</div><div>  vtkSmartPointer<vtkRenderWindow> renderWindow =</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>  vtkSmartPointer<vtkRenderWindow>::New();</div><div>  renderWindow->AddRenderer(renderer);</div><div>  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =</div><div><span class="Apple-tab-span" style="white-space:pre">    </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 id="netease_mail_footer"></span></span>