sub2ind errors with matchFeatures

2 vues (au cours des 30 derniers jours)
Paul Safier
Paul Safier le 23 Avr 2018
Modifié(e) : Paul Safier le 23 Avr 2018
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!!

Réponses (0)

Catégories

En savoir plus sur Feature Detection and Extraction dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by