FreeMat

- Main Page
- Related Pages

vtkImageBlend

Section: Visualization Toolkit Imaging Classes

# Usage

vtkImageBlend takes L, LA, RGB, or RGBA images as input and blends them according to the alpha values and/or the opacity setting for each input.

The spacing, origin, extent, and number of components of the output are the same as those for the first input. If the input has an alpha component, then this component is copied unchanged into the output. In addition, if the first input has either one component or two components i.e. if it is either L (greyscale) or LA (greyscale + alpha) then all other inputs must also be L or LA.

Different blending modes are available:

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
       }
     }

Compound : Images are compounded together and each component is scaled by the sum of the alpha/opacity values. Use the CompoundThreshold method to set specify a threshold in compound mode. Pixels with opacity*alpha less or equal than this threshold are ignored. The alpha value of the first input, if present, is NOT copied to the alpha value of the output. The output always has the same number of components and the same extent as the first input.

     output <- 0
     foreach pixel px {
       sum <- 0
       foreach input i {
         r <- input[i](px)(alpha) * opacity(i)
         sum <- sum + r
         if r > threshold {
           output(px) <- output(px) + input(px) * r
         }
       }
       output(px) <- output(px) / sum
     }

To create an instance of class vtkImageBlend, simply invoke its constructor as follows

      obj = vtkImageBlend

# Methods

The class vtkImageBlend has several methods that can be used. They are listed below. Note that the documentation is translated automatically from the VTK sources, and may not be completely intelligible. When in doubt, consult the VTK website. In the methods listed below, `obj` is an instance of the vtkImageBlend class.

- `string = obj.GetClassName ()`
- `int = obj.IsA (string name)`
- `vtkImageBlend = obj.NewInstance ()`
- `vtkImageBlend = obj.SafeDownCast (vtkObject o)`
- `obj.ReplaceNthInputConnection (int idx, vtkAlgorithmOutput input)` - Replace one of the input connections with a new input. You can only replace input connections that you previously created with AddInputConnection() or, in the case of the first input, with SetInputConnection().
- `obj.SetInput (int num, vtkDataObject input)` - Set an Input of this filter. This method is only for support of old-style pipeline connections. When writing new code you should use SetInputConnection(), AddInputConnection(), and ReplaceNthInputConnection() instead.
- `obj.SetInput (vtkDataObject input)` - Set an Input of this filter. This method is only for support of old-style pipeline connections. When writing new code you should use SetInputConnection(), AddInputConnection(), and ReplaceNthInputConnection() instead.
- `vtkDataObject = obj.GetInput (int num)` - Get one input to this filter. This method is only for support of old-style pipeline connections. When writing new code you should use vtkAlgorithm::GetInputConnection(0, num).
- `vtkDataObject = obj.GetInput ()` - Get one input to this filter. This method is only for support of old-style pipeline connections. When writing new code you should use vtkAlgorithm::GetInputConnection(0, num).
- `int = obj.GetNumberOfInputs ()` - Get the number of inputs to this filter. This method is only for support of old-style pipeline connections. When writing new code you should use vtkAlgorithm::GetNumberOfInputConnections(0).
- `obj.SetOpacity (int idx, double opacity)` - Set the opacity of an input image: the alpha values of the image are multiplied by the opacity. The opacity of image idx=0 is ignored.
- `double = obj.GetOpacity (int idx)` - Set the opacity of an input image: the alpha values of the image are multiplied by the opacity. The opacity of image idx=0 is ignored.
- `obj.SetStencil (vtkImageStencilData stencil)` - Set a stencil to apply when blending the data.
- `vtkImageStencilData = obj.GetStencil ()` - Set a stencil to apply when blending the data.
- `obj.SetBlendMode (int )` - Set the blend mode
- `int = obj.GetBlendModeMinValue ()` - Set the blend mode
- `int = obj.GetBlendModeMaxValue ()` - Set the blend mode
- `int = obj.GetBlendMode ()` - Set the blend mode
- `obj.SetBlendModeToNormal ()` - Set the blend mode
- `obj.SetBlendModeToCompound ()` - Set the blend mode
- `string = obj.GetBlendModeAsString (void )` - Set the blend mode
- `obj.SetCompoundThreshold (double )` - Specify a threshold in compound mode. Pixels with opacity*alpha less or equal the threshold are ignored.
- `double = obj.GetCompoundThreshold ()` - Specify a threshold in compound mode. Pixels with opacity*alpha less or equal the threshold are ignored.