メインコンテンツ

estgeotform2d

マッチする点のペアからの 2 次元幾何学的変換の推定

R2022b 以降

    説明

    tform = estgeotform2d(matchedPoints1,matchedPoints2,transformType) は、1 つのイメージのマッチ点 matchedPoints1 のインライアを別のイメージのマッチ点 matchedPoints2 のインライアにマッピングすることにより、2 つのイメージ間の 2 次元幾何学的変換を推定します。

    [tform,inlierIndex] = estgeotform2d(___) は、さらに、前の構文の入力引数を使用して、マッチ点のペアをインライアまたはアウトライアとして指定するベクトルを返します。

    [tform,inlierIndex,status] = estgeotform2d(___) はさらに、関数が変換を推定できたかどうか、また、推定できなかった場合はその理由を示すステータス コードを返します。status 出力を指定しない場合、関数は結果を生成できない条件に対してエラーを返します。

    [___] = estgeotform2d(___,Name=Value) は、前の構文の引数の任意の組み合わせに加えて、1 つ以上の名前と値の引数を使用して追加のオプションを指定します。たとえば、Confidence=99 は、インライアの最大数を見つけるための信頼度の値を 99 に設定します。

    すべて折りたたむ

    イメージを読み取り、それを表示します。

    original = imread("cameraman.tif");
    imshow(original)
    title("Original Image")

    Figure contains an axes object. The hidden axes object with title Original Image contains an object of type image.

    変換後のイメージを歪めて表示します。

    distorted = imresize(original,0.7); 
    distorted = imrotate(distorted,31);
    
    imshow(distorted)
    title("Transformed Image")

    Figure contains an axes object. The hidden axes object with title Transformed Image contains an object of type image.

    元のイメージと変換後のイメージから特徴を検出して抽出します。

    ptsOriginal  = detectSURFFeatures(original);
    ptsDistorted = detectSURFFeatures(distorted);
    [featuresOriginal,validPtsOriginal] = extractFeatures(original,ptsOriginal);
    [featuresDistorted,validPtsDistorted] = extractFeatures(distorted,ptsDistorted);

    イメージ間の特徴をマッチさせて表示します。

    index_pairs = matchFeatures(featuresOriginal,featuresDistorted);
    matchedPtsOriginal  = validPtsOriginal(index_pairs(:,1));
    matchedPtsDistorted = validPtsDistorted(index_pairs(:,2));
     
    showMatchedFeatures(original,distorted,matchedPtsOriginal,matchedPtsDistorted)
    title("Matched SURF Points With Outliers")

    Figure contains an axes object. The hidden axes object with title Matched SURF Points With Outliers contains 4 objects of type image, line. One or more of the lines displays its values using only markers

    アウトライアを排除して変換行列を推定し、その結果を表示します。

    [tform,inlierIdx] = estgeotform2d(matchedPtsDistorted,matchedPtsOriginal,"similarity");
    inlierPtsDistorted = matchedPtsDistorted(inlierIdx,:);
    inlierPtsOriginal  = matchedPtsOriginal(inlierIdx,:);
     
    showMatchedFeatures(original,distorted,inlierPtsOriginal,inlierPtsDistorted)
    title("Matched Inlier Points")

    Figure contains an axes object. The hidden axes object with title Matched Inlier Points contains 4 objects of type image, line. One or more of the lines displays its values using only markers

    推定した変換を使用して、歪めたイメージから元のイメージを復元して表示します。

    outputView = imref2d(size(original));
    Ir = imwarp(distorted,tform,"OutputView",outputView);
     
    imshow(Ir) 
    title("Recovered Image")

    Figure contains an axes object. The hidden axes object with title Recovered Image contains an object of type image.

    入力引数

    すべて折りたたむ

    最初のイメージのマッチ点。M 個の [x y] 座標から成る M 行 2 列の行列として指定するか、特徴点のタイプで説明されている特徴点オブジェクトの 1 つとして指定します。

    最初のイメージのマッチ点。M 個の [x y] 座標から成る M 行 2 列の行列として指定するか、特徴点のタイプで説明されている特徴点オブジェクトの 1 つとして指定します。

    変換タイプ。"rigid""similarity""affine""projective"、または "translation" として指定します。各変換タイプについて、変換を推定するために、マッチ点のペアの最小数が必要です。一般に、マッチ点のペアの数を増やすと、変換の精度が向上します。次の表は、各変換タイプに関連付けられたオブジェクトのタイプと、変換に必要なマッチ点のペアの最小数を示しています。

    変換タイプtform オブジェクトマッチする点のペアの最小数
    "rigid"rigidtform2d2
    "similarity"simtform2d2
    "affine"affinetform2d3
    "projective"projtform2d4
    "translation"transltform2d1

    データ型: string

    名前と値の引数

    すべて折りたたむ

    オプションの引数のペアを Name1=Value1,...,NameN=ValueN として指定します。ここで、Name は引数名で、Value は対応する値です。名前と値の引数は他の引数の後に指定しなければなりませんが、ペアの順序は重要ではありません。

    例: Confidence=99 は、インライアの最大数を見つけるための信頼度の値を 99 に設定します。

    ランダム試行の最大回数。正の整数として指定します。この値は、関数がマッチ点のペアを見つけるために行うランダムな試行の回数を指定します。より高い値を指定すると、関数は追加の計算を実行し、インライアが見つかる可能性が高くなります。

    データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    最大数のインライアの検出の信頼度。範囲 (0, 100) 内の正の数値スカラーとして指定します。この値を大きくすると、関数は追加の計算を実行し、より多くのインライアが見つかる可能性が高くなります。

    データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    ある点から対応する点の投影までの最大距離。正の数値スカラーとして指定します。MaxDistance は、ある点が対応する点の投影位置と離れていてもインライアと見なされる最大距離をピクセル単位で指定します。対応する投影は、推定された変換に基づきます。

    関数は、matchedPoints1 から matchedPoints2 への変換をチェックし、変換を適用した後、各ペアのマッチ点間の距離を計算します。ペア内のマッチ点間の距離が MaxDistance の値よりも大きかった場合、ペアはその変換のアウトライアと見なされます。距離が MaxDistance より小さかった場合、ペアはインライアであると見なされます。

    A matched point show in image 1 and image 2. Image one shows the point from image 2 projected back onto image 1.

    データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    出力引数

    すべて折りたたむ

    幾何学的変換。rigidtform2d オブジェクト、simtform2d オブジェクト、affinetform2d オブジェクト、projtform2d オブジェクト、または transltform2d オブジェクトとして返されます。

    返された幾何学的変換行列は、matchedPoints1 のインライアを matchedPoints2 のインライアにマッピングします。この関数は、transformType 入力引数で指定された変換タイプ固有のオブジェクトを返します。

    transformType幾何学的変換オブジェクト
    "rigid"rigidtform2d
    "similarity"simtform2d
    "affine"affinetform2d
    "projective"projtform2d
    "translation"transltform2d

    インライアのインデックス。M 行 1 列の logical ベクトルとして返されます。ここで、M は点ペアの数です。各要素には、対応する点ペアがインライアであることを示す logical 1 (true) または対応する点ペアがアウトライアであることを示す logical 0 (false) が格納されます。

    データ型: logical

    ステータス コード。01 または 2 として返されます。ステータス コードは、関数が変換を推定できたかどうか、また、推定できなかった場合は失敗した理由を示します。

    説明
    0エラーなし
    1matchedPoints1 入力と matchedPoints2 入力に十分な数の点が含まれていない
    2十分なインライアが見つからない

    status コード出力を指定しないと、関数は結果を生成できない場合にエラーを返します。

    データ型: int32

    アルゴリズム

    関数は、M-estimator sample consensus (MSAC) アルゴリズムを使用してアウトライアを排除します。MSAC アルゴリズムは、random sample consensus (RANSAC) アルゴリズムのバリアントです。MSAC アルゴリズムのランダム性のために、すべての実行で結果が同一にならない場合があります。

    参照

    [1] Hartley, Richard, and Andrew Zisserman. Multiple View Geometry in Computer Vision. 2nd ed. Cambridge, UK ; New York: Cambridge University Press, 2003.

    [2] Torr, P.H.S., and A. Zisserman. "MLESAC: A New Robust Estimator with Application to Estimating Image Geometry." Computer Vision and Image Understanding. 78, no. 1 (April 2000): 138–56. https://doi.org/10.1006/cviu.1999.0832.

    拡張機能

    すべて展開する

    バージョン履歴

    R2022b で導入

    すべて展開する