Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

estimateGeometricTransform

(非推奨) マッチする点のペアから幾何学的変換を推定

estimateGeometricTransform は推奨されません。代わりに、関数 estgeotform2d または estgeotform3d を使用してください。詳細については、互換性の考慮事項を参照してください。

説明

tform = estimateGeometricTransform(matchedPoints1,matchedPoints2,transformType) は、2 次元幾何学的変換オブジェクト tform を返します。tform オブジェクトは、matchedPoints1 のインライアを matchedPoints2 のインライアにマッピングします。

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

[tform,inlierpoints1,inlierpoints2] = estimateGeometricTransform(matchedPoints1,matchedPoints2,transformType) は、inlierpoints1inlierpoints2 の対応するインライア点を返します。

[___,status] = estimateGeometricTransform(matchedPoints1,matchedPoints2,transformType) は、ステータス コード 01 または 2 を返します。status コードの出力を要求しない場合、関数は結果を生成できない状態に対してエラーを返します。

[___] = estimateGeometricTransform(matchedPoints1,matchedPoints2,transformType, Name,Value) は、名前と値の引数を 1 つ以上指定したオプションを追加で使用します。

すべて折りたたむ

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

original = imread('cameraman.tif');
imshow(original)
title('Base Image')

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

distorted = imresize(original,0.7); 
distorted = imrotate(distorted,31);
figure
imshow(distorted)
title('Transformed 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));
figure 
showMatchedFeatures(original,distorted,matchedPtsOriginal,matchedPtsDistorted)
title('Matched SURF Points With Outliers');

外れ値を排除して変換行列を推定し、その結果を表示します。

[tform,inlierIdx] = estimateGeometricTransform2D(matchedPtsDistorted,matchedPtsOriginal,'similarity');
inlierPtsDistorted = matchedPtsDistorted(inlierIdx,:);
inlierPtsOriginal  = matchedPtsOriginal(inlierIdx,:);

figure 
showMatchedFeatures(original,distorted,inlierPtsOriginal,inlierPtsDistorted)
title('Matched Inlier Points')

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

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

入力引数

すべて折りたたむ

イメージ 1 のマッチ点。KAZEPoints オブジェクト、cornerPoints オブジェクト、SIFTPoints オブジェクト、SURFPoints オブジェクト、MSERRegions オブジェクト、ORBPoints オブジェクト、BRISKPoints オブジェクト、または [x,y] 座標の M 行 2 列の行列として指定します。関数は、M-estimator SAmple Consensus (MSAC) アルゴリズムを使用して外れ値を排除します。MSAC アルゴリズムは、Random Sample Consensus (RANSAC) アルゴリズムのバリアントです。

イメージ 2 のマッチ点。KAZEPoints オブジェクト、cornerPoints オブジェクト、SIFTPoints オブジェクト、SURFPoints オブジェクト、MSERRegions オブジェクト、ORBPoints オブジェクト、BRISKPoints オブジェクト、または [x,y] 座標の M 行 2 列の行列として指定します。関数は、M-estimator SAmple Consensus (MSAC) アルゴリズムを使用して外れ値を排除します。MSAC アルゴリズムは、Random Sample Consensus (RANSAC) アルゴリズムのバリアントです。

変換タイプ。"similarity""affine"、または "projective" として指定します。マッチする点のペアの数が多くなると、推定された変換の精度が高くなります。各変換タイプのマッチする点のペアの最小数は次のとおりです。

変換タイプマッチする点のペアの最小数
"similarity"2
"affine"3
"projective"4

データ型: string | char

名前と値の引数

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

R2021a より前では、コンマを使用して名前と値をそれぞれ区切り、Name を引用符で囲みます。

例: "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

ある点からそれに対応する点の投影までの最大距離 (ピクセル単位)。正の数値スカラーとして指定します。対応する投影は、推定された変換に基づきます。

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

出力引数

すべて折りたたむ

幾何学的変換。affine2d オブジェクトまたは projective2d オブジェクトとして返されます。

返された幾何学的変換行列は、matchedPoints1 のインライアを matchedPoints2 のインライアにマッピングします。transformType 入力を "similarity" または "affine" に設定すると、関数は affine2d オブジェクトを返します。それ以外の場合は projective2d オブジェクトを返します。

イメージ 1 のインライア点。マッチする入力点と同じタイプとして返されます。

イメージ 2 のインライア点。マッチする入力点と同じタイプとして返されます。

ステータス コード。値 01 または 2 として返されます。

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

status コードの出力を要求しない場合、関数は結果を生成できない 2 つの状態に対してエラーをスローします。

データ型: double

参照

[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.

拡張機能

バージョン履歴

R2013a で導入

すべて折りたたむ

R2022b: 非推奨

R2022b 以降、Computer Vision Toolbox™ の多くの関数は、左から乗算する規則を使用して幾何学的変換を作成および実行します。ただし、関数 estimateGeometricTransform は、右から乗算する規則を使用して幾何学的変換を推定します。現時点で estimateGeometricTransform を削除する予定はありませんが、左から乗算する規則をサポートする関数 estgeotform2d および estgeotform3d に切り替えることで、幾何学的変換ワークフローを効率化できます。詳細については、Migrate Geometric Transformations to Premultiply Conventionを参照してください。