Click or drag to resize
Accord.NET (logo)

Blend Class

Linear Gradient Blending filter.
Inheritance Hierarchy
SystemObject
  Accord.Imaging.FiltersBaseTransformationFilter
    Accord.Imaging.FiltersBlend

Namespace:  Accord.Imaging.Filters
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.8.0
Syntax
public class Blend : BaseTransformationFilter
Request Example View Source

The Blend type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyAlphaOnly
Gets or sets a value indicating whether only the alpha channel should be blended. This can be used together with a transparency mask to selectively blend only portions of the image.
Public propertyFillColor
Gets or sets the filling color used to fill blank spaces.
Public propertyFormatTranslations
Format translations dictionary.
(Overrides BaseTransformationFilterFormatTranslations.)
Public propertyGradient
Gets or sets a value indicating whether to blend using a linear gradient or just superimpose the two images with equal weights.
Public propertyHomography
Gets or sets the Homography matrix used to map a image passed to the filter to the overlay image specified at filter creation.
Top
Methods
  NameDescription
Public methodApply(Bitmap)
Apply filter to an image.
(Inherited from BaseTransformationFilter.)
Public methodApply(BitmapData)
Apply filter to an image.
(Inherited from BaseTransformationFilter.)
Public methodApply(UnmanagedImage)
Apply filter to an image in unmanaged memory.
(Inherited from BaseTransformationFilter.)
Public methodApply(UnmanagedImage, UnmanagedImage)
Apply filter to an image in unmanaged memory.
(Inherited from BaseTransformationFilter.)
Protected methodCalculateNewImageSize
Computes the new image size.
(Overrides BaseTransformationFilterCalculateNewImageSize(UnmanagedImage).)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodProcessFilter
Process the image filter.
(Overrides BaseTransformationFilterProcessFilter(UnmanagedImage, UnmanagedImage).)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

The blending filter is able to blend two images using a homography matrix. A linear alpha gradient is used to smooth out differences between the two images, effectively blending them in two images. The gradient is computed considering the distance between the centers of the two images.

The first image should be passed at the moment of creation of the Blending filter as the overlay image. A second image may be projected on top of the overlay image by calling the Apply method and passing the second image as argument.

Currently the filter always produces 32bpp images, disregarding the format of source images. The alpha layer is used as an intermediate mask in the blending process.

Examples
// Let's start with two pictures that have been
// taken from slightly different points of view:
// 
Bitmap img1 = Resources.dc_left;
Bitmap img2 = Resources.dc_right;

// Those pictures are shown below:
ImageBox.Show(img1, PictureBoxSizeMode.Zoom, 640, 480);
ImageBox.Show(img2, PictureBoxSizeMode.Zoom, 640, 480);
// Step 1: Detect feature points using Surf Corners Detector
var surf = new SpeededUpRobustFeaturesDetector();

var points1 = surf.ProcessImage(img1);
var points2 = surf.ProcessImage(img2);

// Step 2: Match feature points using a k-NN
var matcher = new KNearestNeighborMatching(5);
var matches = matcher.Match(points1, points2);

// Step 3: Create the matrix using a robust estimator
var ransac = new RansacHomographyEstimator(0.001, 0.99);
MatrixH homographyMatrix = ransac.Estimate(matches);

// Step 4: Project and blend using the homography
Blend blend = new Blend(homographyMatrix, img1);


// Compute the blending algorithm
Bitmap result = blend.Apply(img2);

// Show on screen
ImageBox.Show(result, PictureBoxSizeMode.Zoom, 640, 480);

The resulting image is shown below.

See Also