On Thu, Feb 17, 2011 at 7:40 AM, Xiaopeng Yang <<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>> wrote:<br>><br>> Wow, that’s a great project! But it is hard for me to understand it. I applied vtkImageBlend to combine the original and mask images. That’s a pretty easy way for me. But I cannot change the mask image color. Do you have any idea to change the mask image color?<br>
><br>> <br>><br>> <br>><br>> vtkSmartPointer<vtkLookupTable> table1 = vtkSmartPointer<vtkLookupTable>::New();<br>><br>> table1->SetRange(100, 150);<br>><br>> table1->SetValueRange(0.0, 1.0);<br>
><br>> table1->SetSaturationRange(0.0, 0.0);<br>><br>> table1->SetRampToLinear();<br>><br>> table1->Build();<br>><br>> <br>><br>> vtkSmartPointer<vtkImageMapToColors> color1 = vtkSmartPointer<vtkImageMapToColors>::New();<br>
><br>> color1->SetLookupTable(table1);<br>><br>> color1->SetInput(Original->GetOutput());//original image<br>><br>> color1->Update();<br>><br>> <br>><br>> vtkSmartPointer<vtkLookupTable> table2 = vtkSmartPointer<vtkLookupTable>::New();<br>
><br>> table2->SetRange(0, 255);<br>><br>> table2->SetValueRange(0,1);<br>><br>> table2->SetSaturationRange(0.0, 0.0);<br>><br>> table2->SetRampToLinear();<br>><br>> table2->Build();<br>
><br>> <br>><br>> vtkSmartPointer<vtkImageMapToColors> color2 = vtkSmartPointer<vtkImageMapToColors>::New();<br>><br>> color2->SetLookupTable(table2);<br>><br>> color2->SetInput(Mask->GetOutput());//mask image<br>
><br>> color2->Update();<br>><br>> <br>><br>> vtkSmartPointer<vtkImageBlend> imgBlender =<br>><br>> vtkSmartPointer<vtkImageBlend>::New();<br>><br>> imgBlender->SetOpacity( 0, 1 );<br>
><br>> imgBlender->SetOpacity( 1, 0.3 );<br>><br>> <br>><br>> imgBlender->SetInput( 0, color1->GetOutput() );<br>><br>> imgBlender->SetInput( 1, color2->GetOutput() );<br>><br>
> <br>><br>> vtkImageViewer2 *imageViewer1 = vtkImageViewer2::New();<br><br>Look at the SetTableValue calls in this example: <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>Also, by using ImageBlend you remove the option (which I always allow) to toggle the mask visibility (well, I suppose you could toggle between the original image and the blended image, but why not just turn on/off the mask?)<br>
<br></div><div>David</div>