connectImagePairs
R2026bDescription
The connectImagePairs function builds a view graph of the
input images for structure-from-motion (SfM) by connecting visually similar images.
Use the connectImagePairs function as the first step in the SfM pipeline
after creating an sfm object, followed by the
verifyImagePairs function, which filters out geometrically inconsistent
connections in the view graph.
The connectImagePairs function detects SIFT features in each image,
computes pairwise similarity using a bag of words vocabulary from the DBoW2 library, and
matches features between candidate pairs. The function then connects image pairs with enough
feature matches as edges in the view graph. For more information about the algorithm, see Algorithms.
specifies additional options using one or more name-value arguments. For example,
sfmObj = connectImagePairs(sfmObj,Name=Value)connectImagePairs(sfmObj,NumSimilarImages=20) searches for
20 similar images per query image instead of the default
10.
Examples
Input Arguments
Name-Value Arguments
Output Arguments
Tips
After using this object function on an
sfmobject, if theisConnectedfunction returnsfalse, useconnectImagePairsagain with an increased value for theNumSimilarImagesargument or a decreased value for theMinNumMatchesargument.To quickly assess which images are connected and identify gaps in coverage, visualize the similarity matrix in
sfmObj.SimilarityMatrixusing theimagescfunction.For larger data sets that contain more images, specifying the
Verboseargument astruecan help you monitor progress.For more information, see Best Practices for 3-D Reconstruction Using Structure from Motion.
Algorithms
In structure‑from‑motion (SfM), view graph construction represents each image as a node and connects pairs of images with edges when they share a sufficient number of matching feature points. The resulting graph captures camera view overlap and determines which image pairs are jointly considered during reconstruction. Organizing images as a view graph enables you to scale the SfM pipeline to large, unordered image collections while prioritizing the most promising image connections for accurate 3‑D reconstruction.
The function constructs the view graph in these stages:
Image retrieval — For each image, the function extracts SIFT features and uses a bag of words representation to retrieve a fixed number of visually similar images as candidate matches. The number of candidates retained per image is controlled by the
NumSimilarImagesargument, which limits the search to the most similar image pairs.Feature matching — For each candidate image pair, the function matches the feature descriptors using a ratio test, to filter ambiguous correspondences, and a matching threshold, to reject weak matches. The ratio test is governed by the
MaxRatioargument, while the descriptor matching threshold is controlled byMatchThreshold. The function adds image pairs that contain at least the minimum number of verified feature matches, as specified byMinNumMatches, as edges in the view graph.
Version History
Introduced in R2026b
See Also
sfm | isConnected | verifyImagePairs | triangulateInitialViews | reconstruct | poses | pointCloud | plot | isVerified | isInitialized









