[vtkusers] Combination of two images

David Gobbi david.gobbi at gmail.com
Wed Apr 13 08:59:42 EDT 2011


Hi Pat,

The vtkImageStencil filter can take two image inputs, try adding this:

IS.SetInput(img);

You can also combine the images without using stencils.  To do this,
you would use vtkImageThreshold to generate your mask image, and then
vtkImageAppend to append this mask to img as an alpha channel.  Then
vtkImageBlend can be used to combine the images, it will use the alpha
channel to decide which pixels to replace.  This method doesn't have
any advantage compared to using stencils, it's just a different way of
doing the same thing.

 - David

On Wed, Apr 13, 2011 at 6:42 AM, Adrien Marion
<adrien.marion at creatis.insa-lyon.fr> wrote:
> Hi,
> I have two vtkImageData (called currentImage and img), each containing
> values from 0 to 250.
> I would like to combine these images to obtain a resulting image (resImage)
> doing for each pixel:
> - if Mask == 0, resImage = currentImage
> - else resImage = Mask
>
> I currently work with VTK wrapped version in Java and I cannot afford a
> triple loop with getScalarAsDoubleComponent to do that.
>
> Does someone have a simple solution to do that ?
>
> I already tried with vtkImageStencil but It does not give the good solution:
>
>        vtkImageToImageStencil IIS = new vtkImageToImageStencil();
>        IIS.SetInput(img);
>        vtkImageStencil IS = new vtkImageStencil();
>        IS.SetStencil(IIS.GetOutput());
>        IS.SetInput(currentImage);
>        IS.Update();
>        result = IS.GetOutput();
>
> I think I did not understand how vtkImageStencil works.
>
> Thank you in advance for your help,
> Adrien
>
> --
> Adrien MARION, Docteur/PhD
> Chercheur post-doctorant (ANR VIP)
> Laboratoire CREATIS, INSA de Lyon
> CNRS UMR 5220, INSERM U1044
> Bâtiment Blaise Pascal, 4ème étage
> 7, avenue Jean Capelle
> 69621 Villeurbanne cedex FRANCE
> Tel : (+33) 4 72 43 87 86
> Fax:  (+33) 4 72 43 85 26
> e-mail : adrien.marion at creatis.insa-lyon.fr
> http://www.creatis.insa-lyon.fr/~amarion



More information about the vtkusers mailing list