[vtkusers] vtkBlend and vtkStencil
David Gobbi
david.gobbi at gmail.com
Thu Oct 28 16:58:56 EDT 2010
Hi Alexis,
The only way to map an image to a new coordinate system before
blending is to use vtkImageReslice. It can take a perspective
transform as input. Also, if you use vtkImageReslice then you might
not need a mask, because you can apply vtkImageReslice to an RGBA
image and it will automatically mark all outside pixels as
transparent.
David
On Wed, Oct 27, 2010 at 5:48 PM, Alexis Cheng <acheng_1221 at hotmail.com> wrote:
> Hi,
>
> I'm using the blend and stencil classes to to map 1 image into a specified
> polygon within another image. An excerpt of my code is as follows.
>
> /////////////////////////////////////////////////////////////////////////////////////////////////
> vtkSmartPointer<vtkImageBlend> blend =
> vtkSmartPointer<vtkImageBlend>::New();
>
> vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
> points->InsertNextPoint(*cnr1X,960 - *cnr1Y,1);
> points->InsertNextPoint(*cnr2X,960 - *cnr2Y,1);
> points->InsertNextPoint(*cnr3X,960 - *cnr3Y,1);
> points->InsertNextPoint(*cnr4X,960 - *cnr4Y,1);
>
> vtkSmartPointer<vtkImplicitSelectionLoop> ImplicitLoop =
> vtkSmartPointer<vtkImplicitSelectionLoop>::New();
> ImplicitLoop->SetLoop(points);
>
> vtkSmartPointer<vtkImplicitFunctionToImageStencil> dataToStencil =
> vtkSmartPointer<vtkImplicitFunctionToImageStencil>::New();
> dataToStencil->SetInput(ImplicitLoop);
>
> blend->SetStencil(dataToStencil->GetOutput());
> blend->AddInput(MTImage);
> blend->AddInput(USImage);
> blend->SetOpacity(0,0.5);
> blend->SetOpacity(1,0.8);
>
> FinalImage = blend->GetOutput());
> FinalImage->Update();
> //////////////////////////////////////////////////////////////////////////////////////////////////
>
> The final result is an image of the first image, MTImage, with a stencil
> window where the 2nd image, USImage, is displayed. My problem is that the
> stencil window is showing that specific portion of USImage, whereas I want
> that stencil window to be a map of USImage (similar to what vtkTexture would
> do). Is it possible to integrate vtkTexture into this setup? Thanks in
> advance.
>
> Thanks,
> Alexis Cheng
> Electrical Engineering
> University of British Columbia
>
> _______________________________________________
> Powered by 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
>
>
More information about the vtkusers
mailing list