Main Content

LocalWeightedMeanTransformation2D

2-D local weighted mean geometric transformation

Description

A LocalWeightedMeanTransformation2D object stores information about a 2-D local weighted mean geometric transformation and enables inverse transformations.

Creation

You can create a LocalWeightedMeanTransformation2D object in these ways.

  • The fitgeotform2d function, which estimates a geometric transformation that maps pairs of control points between two images.

  • The images.geotrans.LocalWeightedMeanTransformation2D described here. This function creates a LocalWeightedMeanTransformation2D object using coordinates of fixed points and moving points, and a specified number of points to use in the local weighted mean calculation.

Description

example

tform = images.geotrans.LocalWeightedMeanTransformation2D(movingPoints,fixedPoints,n) creates a LocalWeightedMeanTransformation2D object that maps control points in the moving image, movingPoints, to control points in the fixed image, fixedPoints, using a local weighted mean transformation. The n closest points are used to infer a second degree polynomial transformation for each control point pair. You can select control points using the cpselect function.

Input Arguments

expand all

Control points in the moving image, specified as an m-by-2 matrix. Each row specifies the (x, y) coordinate of a control point. The number of control points m must be greater than or equal to n.

Data Types: double | single

Control points in the fixed image, specified as an m-by-2 matrix. Each row specifies the (x, y) coordinate of a control point. The number of control points m must be greater than or equal to n.

Data Types: double | single

Number of points to use in the local weighted mean calculation, specified as a positive integer. n can be as small as 6, but making n small risks generating ill-conditioned polynomials

Data Types: double | single | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32

Properties

expand all

Dimensionality of the geometric transformation for both input and output points, specified as the value 2.

Object Functions

outputLimitsFind output spatial limits given input spatial limits
transformPointsInverseApply inverse geometric transformation

Examples

collapse all

Specify six control point pairs. For simplicity, this example calculates the moving point coordinates for a global second degree polynomial transformation.

x = [10, 12, 17, 14, 7, 10];
y = [8, 2, 6, 10, 20, 4];
 
a = [1 2 3 4 5 6];
b = [2.3 3 4 5 6 7.5];
 
u = a(1) + a(2).*x + a(3).*y + a(4) .*x.*y + a(5).*x.^2 + a(6).*y.^2;
v = b(1) + b(2).*x + b(3).*y + b(4) .*x.*y + b(5).*x.^2 + b(6).*y.^2;
 
fixedPoints = [x; y]';
movingPoints = [u; v]'
movingPoints = 6×2
103 ×

    1.2490    1.5443
    0.8710    1.0603
    2.1220    2.5913
    2.1990    2.7103
    3.2800    4.0973
    0.7890    0.9683

Estimate a local weighted mean transformation that fits fixedPoints and movingPoints.

tform = images.geotrans.LocalWeightedMeanTransformation2D(movingPoints,fixedPoints,6)
tform = 
  LocalWeightedMeanTransformation2D with properties:

    Dimensionality: 2

Verify that the inverse transformation maps the fixed points to the moving points.

movingPointsComputed = transformPointsInverse(tform,fixedPoints)
movingPointsComputed = 6×2
103 ×

    1.2490    1.5443
    0.8710    1.0603
    2.1220    2.5913
    2.1990    2.7103
    3.2800    4.0973
    0.7890    0.9683

Algorithms

The local weighted mean transformation infers a polynomial at each control point using neighboring control points. The mapping at any location depends on a weighted average of these polynomials. The n closest points are used to infer a second degree polynomial transformation for each control point pair. n can be as small as 6, but making it small risks generating ill-conditioned polynomials.

Version History

Introduced in R2013b