[vtkusers] [Insight-users] Overlay segmented binary image on vtkImageViewer2
David Doria
daviddoria at gmail.com
Thu Feb 17 07:55:51 EST 2011
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/158c2cfd/attachment.htm>
More information about the vtkusers
mailing list