Performing automatic image-to-image matching
The basic steps for performing automatic image-to-image matching are as follows:
- Compute the match points of the two images (assuming the two images have overlaps) using the ImageRegistration class.
- Extract source and target control points from the matching points for use in the RasterGeometryProc class.
See the following code example:
[C#] void ImageMatchingExample(IRaster ras, IRaster ras_ref)
{
// Create the ImageRegistration object and compute the image matching points.
IImageRegistration imageRegistration=new ImageRegistrationClass();
IImageMatchPoints matchPoints=imageRegistration.ExtractMatchPoints(ras,
ras_ref);
// Extract the collection of matching points as source and target points.
IPointCollection sourcePoints=new MultipointClass();
IPointCollection targetPoints=new MultipointClass();
for (int i=0; i < matchPoints.Count; i++)
{
IImageMatchPoint matchPoint=matchPoints.get_Element(i);
IImageFeaturePoint imageFromPoint=matchPoint.From;
IImageFeaturePoint imageToPoint=matchPoint.To;
sourcePoints.AddPoint(imageFromPoint.Location);
targetPoints.AddPoint(imageToPoint.Location);
}
IRasterGeometryProc rasProc=new RasterGeometryProcClass();
rasProc.Warp(sourcePoints, targetPoints,
esriGeoTransTypeEnum.esriGeoTransPolyOrder2, ras);
rasProc.Register(ras);
}
[VB.NET] Private Sub ImageMatchingExample(ras As IRaster, ras_ref As IRaster)
' Create the ImageRegistration object and compute the image matching points.
Dim imageRegistration As IImageRegistration=New ImageRegistrationClass()
Dim matchPoints As IImageMatchPoints=imageRegistration.ExtractMatchPoints(ras, ras_ref)
' Extract the collection of matching points as source and target points.
Dim sourcePoints As IPointCollection=New MultipointClass()
Dim targetPoints As IPointCollection=New MultipointClass()
For i As Integer=0 To matchPoints.Count - 1
Dim matchPoint As IImageMatchPoint=matchPoints.get_Element(i)
Dim imageFromPoint As IImageFeaturePoint=matchPoint.From
Dim imageToPoint As IImageFeaturePoint=matchPoint.[To]
sourcePoints.AddPoint(imageFromPoint.Location)
targetPoints.AddPoint(imageToPoint.Location)
Next
Dim rasProc As IRasterGeometryProc=New RasterGeometryProcClass()
rasProc.Warp(sourcePoints, targetPoints, esriGeoTransTypeEnum.esriGeoTransPolyOrder2, ras)
rasProc.Register(ras)
End Sub
To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |