首页 文章

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

提问于
浏览
0

在计算机视觉系统工具箱的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

    我尝试使用示例图像的代码(稍微更改一下)并且它可以工作:

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

相关问题