[vtkusers] how to change vtkImageBlend opacity
David Gobbi
david.gobbi at gmail.com
Mon Mar 7 09:49:19 EST 2016
Hi Muhammad,
Remove vtkImageBlend from your pipeline. Use the SetOpacity() method on
vtkLookupTable.
- David
On Mon, Mar 7, 2016 at 7:33 AM, Muhammad Jawad <softplanner at gmail.com>
wrote:
> Hi David,
>
> thanks for your suggestions. I did the same as you mentioned, It add
> lookup table still opacity is not working. Perhaps, I did some wrong in my
> code.
>
> connectorDicom = LoadDicomReader(dirPath.toStdString());
>
>
> vtkSmartPointer<vtkLookupTable> imgFirstColorMap = vtkSmartPointer<vtkLookupTable>::New(); // hot color map
>
> imgFirstColorMap->SetRange( 0.0, 255.0 );
>
> imgFirstColorMap->SetHueRange( 0.0, 0.1 );
>
> imgFirstColorMap->SetValueRange( 0.4, 0.8 );
>
> imgFirstColorMap->Build();
>
>
> vtkSmartPointer<vtkImageMapToColors> firstColorMapper = vtkSmartPointer<vtkImageMapToColors>::New();
>
> firstColorMapper->SetInputData(connectorDicom->GetOutput());
>
> firstColorMapper->SetLookupTable( imgFirstColorMap );
>
> firstColorMapper->SetOutputFormatToRGBA();
>
> firstColorMapper->Update();
>
>
> blend->SetOpacity(0,0);
>
> blend->AddInputConnection(firstColorMapper->GetOutputPort());
>
> imgViewer->SetInputData(blend->GetOutput());
>
> imgViewer->UpdateDisplayExtent();
>
>
>
> Muhammad Jawad
>
>
> On 7 March 2016 at 14:53, David Gobbi <david.gobbi at gmail.com> wrote:
>
>> Hi Muhammad,
>>
>> The vtkImageBlend filter does not add an alpha component to the image.
>> If the first input to vtkImageBlend is RGB, then the output is RGB. This
>> filter will blend its inputs together, but given just one input, the output
>> will just be a copy of the input.
>>
>> If your image is greyscale, you can use vtkImageMapToColors to add an
>> alpha component, by using the SetOutputFormatToRGBA() option.
>>
>> - David
>>
>> On Mon, Mar 7, 2016 at 4:05 AM, Muhammad Jawad <softplanner at gmail.com>
>> wrote:
>>
>>>
>>> Dear Vtk users,
>>>
>>> I am using vtkimageblend class for multiple volumes and want to change
>>> opacity of volumes. Here I put the small code for single volume for
>>> simplicity.
>>>
>>> ImageViewer is working fine but opacity is not working.
>>>
>>>
>>> Any body have an idea that what I'm doing wrong here ?
>>>
>>>
>>> vtkSmartPointer<vtkImageBlend> blend = vtkSmartPointer<vtkImageBlend>::New();
>>>
>>>
>>> blend->SetInputData(0, reader->GetOutput());
>>>
>>>
>>> blend->SetOpacity(0, 0.3);
>>>
>>>
>>> vtkSmartPointer<vtkImageViewer2> imgViewer = vtkSmartPointer<vtkImageViewer2>::New();
>>>
>>>
>>> imgViewer->SetInputData(blend->GetOutput());
>>>
>>>
>>> imgViewer->UpdateDisplayExtent();
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>> Regards,
>>>
>>> Muhammad Jawad
>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160307/11f3f400/attachment.html>
More information about the vtkusers
mailing list