[vtkusers] Not able to blend properly

anupriya.sharma at accenture.com anupriya.sharma at accenture.com
Wed Oct 3 01:32:34 EDT 2012


Hi,

Thanks for your reply.

But I tried to change the alpha value in the Lookup Table of the first input to 0 and tried to set the opacity value of the 2nd input as 1. Then also the result is coming incorrect(white screen is shown,no output is displayed). The expected result should be that the 1st input is perfectly transparent so only 2nd input should be shown in the output.


First Input LUT(changed the alpha value to 0)
for (int i = 0; i < 4096; i++)
                {
                    string str = read.ReadLine();
                    string[] value = str.Split(',');
                    double[] colorValue = new double[5];
                    for (int j = 0; j < 5; j++)
                    {

                        colorValue[j] = Convert.ToDouble(value[j]);

                    }
                        table.SetTableValue((long)colorValue[0], colorValue[1], colorValue[2], colorValue[3], 0);

                }


Setting the opacity of second Input

blend.SetOpacity(1, 1);

Can you please explain this behavior?


Regards,
Anupriya

From: Jagjeet Nain [mailto:jagjeet.nain at gmail.com]
Sent: Monday, October 01, 2012 7:35 PM
To: Sharma, Anupriya
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Not able to blend properly

Hi,
it works following way:
Normal (default) : This is the standard blending mode used by OpenGL and other graphics packages. The output always has the same number of components and the same extent as the first input. The alpha value of the first input is not used in the blending computation, instead it is copied directly to the output.

output <- input[0]
foreach input i {
  foreach pixel px {
    r <- input[i](px)(alpha) * opacity[i]
    f <- (255 - r)
    output(px) <- output(px) * f + input(px) * r
  }
}

Cheers
On Mon, Oct 1, 2012 at 7:40 AM,  <anupriya.sharma at accenture.com<mailto:anupriya.sharma at accenture.com>> wrote:
> Hi
>
>
>
> I am trying to blend two different raw files. I have used vtkImageReader to
> read both the files. I have applied two different lookup tables on both the
> file
>
> I have also  used          vtkImageMapToColors ColorMapper = new
> vtkImageMapToColors();
>
>
>
>                 vtkImageMapToColors ColorMapper = new vtkImageMapToColors();
>
>                 ColorMapper.SetInput(reader1.GetOutput());
>
>                 ColorMapper.SetLookupTable(table);
>
>
>
>                 vtkImageMapToColors ColorMapper1 = new
> vtkImageMapToColors();
>
>                 ColorMapper1.SetInput(reader2.GetOutput());
>
>                 ColorMapper1.SetLookupTable(table1);
>
>
>
> "table is the Lookuptable applied on first file and table1 is the lookup
> table applied on second file".
>
>
>
> After setting the lookuptable I have created instance of vtkImage blend.
>
>
>
> vtkImageBlend blend = new vtkImageBlend();
>
> blend.setOpacity(0,0);
>
> blend.setOpacity(1,0);
>
> blend.AddInputConnection(ColorMapper.GetOutputPort);
>
> blend.AddInputConnection(ColorMapper1.GetOutputPort);
>
>
>
> I have later given the output of blend to the Input Connection of Viewer.
>
> Viewer.SetInputConnection(blend.GetOutputPort());
>
>
>
> But the problem is the opacity results are coming incorrect.
>
>
>
> If the opacity of first file is 0 and the opacity of second file is also 0
> then no output should be displayed but the output is getting displayed with
> color of first LUT i.e Green.
>
> If the opacities are 0.5 and 0.5(0.5 opacity for both the files) then the
> fused color (dark green ) is getting displayed. The same color is getting
> displayed at opacities 0 and 0.5(0 for first file and 0.5 for second).The
> same thing is happening with opacities 1 and 0.5(1 for first file and 0.5
> for second).
>
>
>
> Could anyone please explain how this Opacity function is working and how to
> blend two different files with different color tables.
>
>
>
>
>
>
>
> Regards
>
> Anupriya Sharma
>
>
>
>
> ________________________________
> Subject to local law, communications with Accenture and its affiliates
> including telephone calls and emails (including content), may be monitored
> by our systems for the purposes of security and the assessment of internal
> compliance with Accenture policy.
> ______________________________________________________________________________________
>
> www.accenture.com<http://www.accenture.com>
>
> _______________________________________________
> Powered by www.kitware.com<http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>

________________________________
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________

www.accenture.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121003/82d22e67/attachment.htm>


More information about the vtkusers mailing list