[vtkusers] vtkBlend and vtkStencil

Alexis Cheng acheng_1221 at hotmail.com
Wed Oct 27 19:48:34 EDT 2010


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
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101027/67aea1e7/attachment.htm>


More information about the vtkusers mailing list