马特实验室"Subscript indices must either be real positive integers or logicals"



在计算机视觉系统工具箱的 MATLAB 示例页面中,有一个使用点特征匹配在杂乱场景中检测对象的代码。我在我的系统上运行相同的代码,但它给出错误"下标索引必须是真正的正整数或逻辑",其中代码试图匹配两个图像之间的相似性。

I1 = rgb2gray(imread('kitchen.jpg'));
I2 = rgb2gray(imread('loops.jpg'));
points1 = detectSURFFeatures(I1);
points2 = detectSURFFeatures(I2);
[features1, valid_points1] = extractFeatures(I1, points1);
[features2, valid_points2] = extractFeatures(I2, points2);
indexPairs = matchFeatures(features1, features2);
matchedPoints1 = valid_points1(indexPairs(:, 1), :);    //ERROR
matchedPoints2 = valid_points2(indexPairs(:, 2), :);
figure; showMatchedFeatures(I1, I2, matchedPoints1, matchedPoints2);

我是 MATLAB 的新手,只是想理解这些概念,但我陷入了困境。任何帮助,不胜感激。谢谢。

我用示例图像尝试了您的代码(有一些细微的更改),它起作用了:

//open the image
I = rgb2gray(imread('img_0236.jpg'));
//extract the left stereo image
I1 = I(:,1:800);
//extract the right stereo image
I2 = I(:,801:1600);
points1 = detectSURFFeatures(I1);
points2 = detectSURFFeatures(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);

我从以下位置下载了示例图像: http://www.stereomaker.net/java/spva/img_0236.jpg

相关内容

最新更新