MATLAB“下标索引必须是真正的正整数或逻辑”

时间:2016-02-29 04:13:49

标签: matlab

在计算机视觉系统工具箱的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的新手,只是试图理解这些概念,但我陷入了困境。任何帮助表示赞赏。谢谢。

1 个答案:

答案 0 :(得分:0)

我尝试使用示例图像编写代码(稍作修改),然后就可以了:

//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

下载了示例图片