Main Content

matchFeatures

매칭되는 특징 찾기

설명

예제

indexPairs = matchFeatures(features1,features2)는 2개의 입력 특징 세트에서 매칭되는 특징의 인덱스를 반환합니다. 입력 특징은 binaryFeatures 객체 또는 행렬이어야 합니다.

[indexPairs,matchmetric] = matchFeatures(features1,features2)indexPairs로 인덱싱된 매칭 특징 사이의 거리도 반환합니다.

[indexPairs,matchmetric] = matchFeatures(features1,features2,Name=Value)는 위에 열거된 구문의 인수 조합 외에 하나 이상의 이름-값 인수를 사용하여 옵션을 지정합니다. 예를 들어 matchFeatures(__,Method="Exhaustive")는 매칭 방법을 Exhaustive로 설정합니다.

예제

모두 축소

국소 이웃과 Harris 알고리즘을 사용하여 한 쌍의 영상 사이에서 대응하는 관심점을 찾습니다.

스테레오 영상을 읽어 들입니다.

I1 = im2gray(imread("viprectification_deskLeft.png"));
I2 = im2gray(imread("viprectification_deskRight.png"));

코너를 찾습니다.

points1 = detectHarrisFeatures(I1);
points2 = detectHarrisFeatures(I2);

이웃 특징을 추출합니다.

[features1,valid_points1] = extractFeatures(I1,points1);
[features2,valid_points2] = extractFeatures(I2,points2);

특징을 매칭시킵니다.

indexPairs = matchFeatures(features1,features2);

각 영상에 대한 대응점의 위치를 가져옵니다.

matchedPoints1 = valid_points1(indexPairs(:,1),:);
matchedPoints2 = valid_points2(indexPairs(:,2),:);

대응점을 시각화합니다. 몇몇 잘못된 매칭점이 있지만 두 영상 사이에서 평행 이동의 효과를 확인할 수 있습니다.

figure; 
showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2);

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

두 영상을 읽어 들입니다.

I1 = imread("cameraman.tif");
I2 = imresize(imrotate(I1,-20),1.2);

SURF 특징을 찾습니다.

points1 = detectSURFFeatures(I1);
points2 = detectSURFFeatures(I2);

특징을 추출합니다.

[f1,vpts1] = extractFeatures(I1,points1);
[f2,vpts2] = extractFeatures(I2,points2);

매칭되는 점들의 위치를 가져옵니다.

indexPairs = matchFeatures(f1,f2) ;
matchedPoints1 = vpts1(indexPairs(:,1));
matchedPoints2 = vpts2(indexPairs(:,2));

매칭 점을 표시합니다. 데이터에 몇몇 이상값이 여전히 들어 있지만, 매칭된 특징들을 표시하면 회전과 스케일링의 효과를 확인할 수 있습니다.

figure; showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2);
legend("matched points 1","matched points 2");

Figure contains an axes object. The axes object contains 4 objects of type image, line. One or more of the lines displays its values using only markers These objects represent matched points 1, matched points 2.

입력 인수

모두 축소

특징 세트 1로, binaryFeatures 객체, M1×N 행렬, 또는 Point Feature Types에 설명되어 있는 특징점 객체 중 하나로 지정됩니다. 이 행렬은 M1개의 특징을 포함하며, N은 각 특징 벡터의 길이에 해당합니다. extractFeatures 함수를 FREAK(Fast Retina Keypoint), ORB(Oriented FAST and Rotated BRIEF) 또는 BRISK(Binary Robust Invariant Scalable Keypoints) 설명자 방법과 함께 사용하여 binaryFeatures 객체를 얻을 수 있습니다.

특징 세트 2로, binaryFeatures 객체, M2×N 행렬, 또는 Point Feature Types에 설명되어 있는 특징점 객체 중 하나로 지정됩니다. 이 행렬은 M2개의 특징을 포함하며, N은 각 특징 벡터의 길이에 해당합니다. extractFeatures 함수를 FREAK(Fast Retina Keypoint), ORB(Oriented FAST and Rotated BRIEF) 또는 BRISK(Binary Robust Invariant Scalable Keypoints) 설명자 방법과 함께 사용하여 binaryFeatures 객체를 얻을 수 있습니다.

이름-값 인수

선택적 인수 쌍을 Name1=Value1,...,NameN=ValueN으로 지정합니다. 여기서 Name은 인수 이름이고 Value는 대응값입니다. 이름-값 인수는 다른 인수 뒤에 와야 하지만, 인수 쌍의 순서는 상관없습니다.

R2021a 이전 릴리스에서는 쉼표를 사용하여 각 이름과 값을 구분하고 Name을 따옴표로 묶으십시오.

예: Method="Exhaustive"는 매칭 방법을 Exhaustive로 설정함

매칭 방법으로, "Exhaustive" 또는 "Approximate"로 지정됩니다. 이 방법은 features1features2 사이의 최근접이웃을 찾는 방법을 지정합니다. 두 특징 벡터 사이의 거리가 MatchThreshold 파라미터로 설정된 임계값보다 작으면 두 특징 벡터가 매칭됩니다.

"Exhaustive"

features1features2의 특징 벡터 사이의 쌍별 거리를 계산합니다.

"Approximate"

효율적인 근사 최근접이웃 탐색을 사용합니다. 특징 세트가 큰 경우 이 방법을 사용하십시오. [3]

매칭 임계값으로, (0,100] 범위의 스칼라 백분율 값으로 지정됩니다. 디폴트 값은 이진 특징 벡터의 경우 10.0, 비이진 특징 벡터의 경우 1.0으로 설정됩니다. 매칭 임계값을 사용하여 가장 유력한 매칭점을 선택할 수 있습니다. 임계값은 완벽한 매칭으로부터의 거리를 백분율로 나타냅니다.

두 특징 벡터 사이의 거리가 MatchThreshold로 설정된 임계값보다 작으면 두 특징 벡터가 매칭됩니다. 함수는 두 특징 사이의 거리가 MatchThreshold 값보다 크면 매칭을 기각합니다. 더 많은 매칭점을 반환하려면 값을 늘리십시오.

입력값이 binaryFeatures 객체인 경우 일반적으로 매칭 임계값에 더 큰 값이 필요합니다. extractFeatures 함수는 FREAK, ORB 또는 BRISK 설명자를 추출할 때 binaryFeatures 객체를 반환합니다.

비율 임계값으로, (0,1] 범위의 스칼라 비율 값으로 지정됩니다. 모호한 매칭점을 기각하려면 최대 비율을 사용하십시오. 매칭점을 더 많이 반환하려면 이 값을 늘리십시오.

특징 매칭 메트릭으로, "SAD" 또는 "SSD"로 지정됩니다.

"SAD"절대차이합
"SSD"차이제곱합

이 속성은 입력 특징 세트 features1features2binaryFeatures 객체가 아닐 때 적용됩니다. 특징을 binaryFeatures 객체로 지정하면 함수는 해밍 거리를 사용하여 유사도 메트릭을 계산합니다.

고유한 매칭점으로, false 또는 true로 지정됩니다. features1features2 사이의 고유한 매칭점만 반환하려면 이 값을 true로 설정합니다.

Uniquefalse로 설정하면 함수는 features1features2 사이의 모든 매칭점을 반환합니다. features1의 여러 특징이 features2의 하나의 특징과 매칭될 수 있습니다.

column representing features 1 with entry 1 and 3 circled and pointing to entry 2 of a column representing features 2

Uniquetrue로 설정하면 함수가 순방향-역방향 매칭을 수행하여 고유한 매칭점을 선택합니다. features1features2에 매칭한 후에 features2features1에 매칭하여 최적의 매칭을 선택합니다.

출력 인수

모두 축소

두 입력 특징 세트 사이에 대응하는 특징의 인덱스로, P개의 인덱스로 구성된 P×2 행렬로 반환됩니다. 각 인덱스 쌍은 features1features2 입력값 사이에 매칭되는 특징에 대응합니다. 첫 번째 요소는 features1의 특징을 인덱싱합니다. 두 번째 요소는 features2에서 매칭되는 특징을 인덱싱합니다.

매칭되는 특징 사이의 거리로, p×1 벡터로 반환됩니다. 거리 값은 선택한 메트릭을 기반으로 합니다. matchmetric의 각 i번째 요소는 indexPairs 출력 행렬의 i번째 행에 대응합니다. MetricSAD 또는 SSD로 설정된 경우 특징 벡터는 계산 전에 단위 벡터로 정규화됩니다.

메트릭범위완벽한 매칭 값
SAD[0, 2*sqrt(size(features1, 2))]. 0
SSD[0,4]0
Hamming[0, features1.NumBits]0

참고 문헌

[1] Lowe, David G. "Distinctive Image Features from Scale-Invariant Keypoints." International Journal of Computer Vision. Volume 60, Number 2, pp. 91–110.

[2] Muja, M., and D. G. Lowe. "Fast Matching of Binary Features. "Conference on Computer and Robot Vision. CRV, 2012.

[3] Muja, M., and D. G. Lowe. "Fast Approximate Nearest Neighbors with Automatic Algorithm Configuration." International Conference on Computer Vision Theory and Applications.VISAPP, 2009.

[4] Rublee, E., V. Rabaud, K. Konolige and G. Bradski. "ORB: An efficient alternative to SIFT or SURF." In Proceedings of the 2011 International Conference on Computer Vision, 2564–2571. Barcelona, Spain, 2011.

확장 기능

버전 내역

R2011a에 개발됨