sub2ind errors with matchFeatures

조회 수: 2 (최근 30일)
Paul Safier
Paul Safier 2018년 4월 23일
편집: Paul Safier 2018년 4월 23일
Hello! I'm trying to start with the code for image registration given here, and convert it for my needs:
When I test the code with two identical matrices/images (i.e. no misalignment as a test) I get the errors:
Error using sub2ind (line 47)
The subscript vectors must all be of the same size.
Error in cvalgMatchFeatures>partialSort (line 301)
inds = sub2ind(size(x), 1:size(x, 1), indices(i, :));
Error in cvalgMatchFeatures>findMatchesNNRatio (line 215)
[values, col_indices] = partialSort(scores, 2, 'ascend');
Error in cvalgMatchFeatures>findMatches (line 135)
[index_pairs, match_metric] = findMatchesNNRatio(scores,...
Error in cvalgMatchFeatures (line 65)
[index_pairs, match_metric] = findMatches(scores, N1, N2, metric, ...
Error in matchFeatures (line 207)
[index_pairs_internal, match_metric_internal] = ...
My code is:
fixed = A;
distort = fixed;
ptsOriginal = detectSURFFeatures(fixed);
ptsDistorted = detectSURFFeatures(distort);
[featuresOriginal, validPtsOriginal] = extractFeatures(fixed, ptsOriginal);
[featuresDistorted, validPtsDistorted] = extractFeatures(distort, ptsDistorted);
indexPairs = matchFeatures(featuresOriginal, featuresDistorted);
matchedOriginal = validPtsOriginal(indexPairs(:,1));
matchedDistorted = validPtsDistorted(indexPairs(:,2));
tform, inlierDistorted, inlierOriginal] = estimateGeometricTransform(...
matchedDistorted, matchedOriginal, 'similarity');
outputView = imref2d(size(fixed));
recovered = imwarp(distort,tform,'OutputView',outputView);
The error comes at this step:
indexPairs = matchFeatures(featuresOriginal, featuresDistorted);
I've tried several other matrices to test alignment and some work and some give this same error. I printed out the size of the matrix arguments to the matchFeatures function and they are matched in size, every time. I have had several instances where this error occurs when trying to align an image to itself(!) as a test! Can anyone help?
Thanks!!

답변 (0개)

카테고리

Help CenterFile Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by