[vtkusers] [Insight-users] Overlay segmented binary image on vtkImageViewer2

Xiaopeng Yang yxp233 at postech.ac.kr
Thu Feb 17 08:30:32 EST 2011


Great idea David. I will try your idea.

 

Thanks a lot,

Yang

 

发件人: David Doria [mailto:daviddoria at gmail.com] 
发送时间: 2011년 2월 17일 목요일 오후 9:56
收件人: Xiaopeng Yang
抄送: vtk; insight-users at itk.org
主题: Re: [Insight-users] Overlay segmented binary image on vtkImageViewer2

 

On Thu, Feb 17, 2011 at 7:40 AM, Xiaopeng Yang <yxp233 at postech.ac.kr> wrote:
>
> 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?
>
>  
>
>  
>
>   vtkSmartPointer<vtkLookupTable> table1 = vtkSmartPointer<vtkLookupTable>::New();
>
>   table1->SetRange(100, 150);
>
>   table1->SetValueRange(0.0, 1.0);
>
>   table1->SetSaturationRange(0.0, 0.0);
>
>   table1->SetRampToLinear();
>
>   table1->Build();
>
>  
>
>   vtkSmartPointer<vtkImageMapToColors> color1 = vtkSmartPointer<vtkImageMapToColors>::New();
>
>   color1->SetLookupTable(table1);
>
>   color1->SetInput(Original->GetOutput());//original image
>
> color1->Update();
>
>  
>
>   vtkSmartPointer<vtkLookupTable> table2 = vtkSmartPointer<vtkLookupTable>::New();
>
>   table2->SetRange(0, 255);
>
>   table2->SetValueRange(0,1);
>
>   table2->SetSaturationRange(0.0, 0.0);
>
>   table2->SetRampToLinear();
>
>   table2->Build();
>
>  
>
>   vtkSmartPointer<vtkImageMapToColors> color2 = vtkSmartPointer<vtkImageMapToColors>::New();
>
>   color2->SetLookupTable(table2);
>
>   color2->SetInput(Mask->GetOutput());//mask image
>
>   color2->Update();
>
>  
>
>   vtkSmartPointer<vtkImageBlend> imgBlender =
>
>       vtkSmartPointer<vtkImageBlend>::New();
>
>   imgBlender->SetOpacity( 0, 1 );
>
>   imgBlender->SetOpacity( 1, 0.3 );
>
>  
>
>   imgBlender->SetInput( 0, color1->GetOutput() );
>
>   imgBlender->SetInput( 1, color2->GetOutput() );
>
>  
>
> vtkImageViewer2 *imageViewer1 = vtkImageViewer2::New();

Look at the SetTableValue calls in this example: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/Transparency 

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?)

David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110217/6a1d3dce/attachment.htm>


More information about the vtkusers mailing list