[vtkusers] Complementary color LUTs

David Gobbi david.gobbi at gmail.com
Wed Apr 20 03:15:33 EDT 2016


Hi Jothy,

I see this mistake a lot... people try to blend images by setting the alpha
of both images to 0.5.  That's wrong.  If you want to blend images, then
the first image should be opaque, and the second image should have an alpha
of 0.5.

C = C1*(1 - alpha2) + C2*alpha2

The second mistake is that, if you want to blend complimentary colors, then
you don't want the Value of the second image to be the ramp.  Instead, you
want the Alpha of the second image to be the ramp.

    // Create a GREEN lookup table
    vtkSmartPointer<vtkLookupTable> table =
            vtkSmartPointer<vtkLookupTable>::New();
    table->SetHueRange(0.33333,0.33333);
    table->SetSaturationRange(1.0,1.0);
    table->SetValueRange(0.0,1.0);
    table->SetAlphaRange(1.0,1.0); // make the bottom image opaque
    table->SetRampToLinear();
    table->Build();

    // Create a MAGENTA lookup table
    vtkSmartPointer<vtkLookupTable>table2 =
            vtkSmartPointer<vtkLookupTable>::New();
    table2 ->SetHueRange(0.8333,0.8333);
    table2 ->SetSaturationRange(1.0,1.0);
    table2 ->SetValueRange(1.0,1.0); // use pure magenta, don't mix with
black
    table2 ->SetAlphaRange(0.0,1.0); // use an alpha ramp to blend the
images
    table2 ->SetRampToLinear();
    table2 ->Build();

- David

On Tue, Apr 19, 2016 at 11:43 PM, Jothybasu Selvaraj <jothybasu at gmail.com>
wrote:

> Hi All
>
> I am trying to overlay 2 registered images using complementary LUTs
> (magenta & green), so that the images will appear white where they match
> perfectly. However, I couldn't get the desired results. The image appears
> magenta where they match.
>
> Can anyone find any mistakes in this?
>
> Below are the LUTs I use:
>
> // Create a GREEN lookup table
>
>     vtkSmartPointer<vtkLookupTable> table =
>
>             vtkSmartPointer<vtkLookupTable>::New();
>
>     table->SetHueRange(0.33333,0.33333);
>
>     table->SetSaturationRange(1.0,1.0);
>
>     table->SetValueRange(0.0,1.0);
>
>     table->SetAlpha(0.5);
>
>     table->SetRampToLinear();
>
>     table->Build();
>
>
> // Create a MAGENTA lookup table
>
>     vtkSmartPointer<vtkLookupTable>table2 =
>
>             vtkSmartPointer<vtkLookupTable>::New();
>
>     table2 ->SetHueRange(0.8333,0.8333);
>
>     table2 ->SetSaturationRange(1.0,1.0);
>
>     table2 ->SetValueRange(0.0,1.0);
>
>     table2 ->SetAlpha(0.5);
>
>     table2 ->SetRampToLinear();
>
>     table2 ->Build();
>
>
> Any help is highly appreciated!
>
>
>
> Cheers
>
>
> Jothy
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160420/b3d7501a/attachment.html>


More information about the vtkusers mailing list