[vtkusers] vtkImageBlend output alpha

David Gobbi david.gobbi at gmail.com
Thu Jul 20 08:32:59 EDT 2017


Hi Mike,

There is no way to change this behavior for vtkImageBlend.  One solution is
to use a dummy image as input 0 (same dimensions as your first image, but
with RGBA set to 0,0,0,1 for all pixels), and then add your two images as
inputs 1 and 2.

 - David

On Wed, Jul 19, 2017 at 10:49 AM, Mike Withascarf via vtkusers <
vtkusers at vtk.org> wrote:

> Hi, I'm using vtkImageBlend to blend two vtkImageMapToColors. Right now if
> I change the opacity map of the first vtkImageMapToColors (via lookup
> table), it adjusts the entire alpha of the output (so for example hiding
> the first one hides both of them). Is there a way to prevent vtkImageBlend
> from assigning the opacity of the first element to the output? I've tried
> using the "compound" blending mode in case that would help, but the screen
> is blank then. Any help would be great!
>
> This is a simplified version of the code I'm using:
>
> vtkSmartPointer<vtkImageMapToColors> imapper1 =
> vtkSmartPointer<vtkImageMapToColors>::New();
> imapper1->SetLookupTable(lut1);
> imapper1->PassAlphaToOutputOn();
> imapper1->SetInputData(image1);
> imapper1->Update();
>
> vtkSmartPointer<vtkImageMapToColors> imapper2 =
> vtkSmartPointer<vtkImageMapToColors>::New();
> imapper2->SetLookupTable(lut2);
> imapper2->PassAlphaToOutputOn();
> imapper2->SetInputData(image2);
> imapper2->Update();
>
> vtkSmartPointer<vtkImageBlend> blend = vtkSmartPointer<vtkImageBlend>
> ::New();
> blend->AddInputConnection(imapper1->GetOutputPort());
> blend->SetOpacity(0, 1.0);
> blend->AddInputConnection(imapper2->GetOutputPort());
> blend->SetOpacity(1, 1.0);
>
> // If I now render and adjust lut1, it affects the output of blend so the
> imapper2 image gets affected
>
> Mike
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170720/1d56fe15/attachment.html>


More information about the vtkusers mailing list