0
votes

In the MATLAB examples page for Computer Vision System Toolbox, there is a code for Object Detection in a Cluttered Scene Using Point Feature Matching. I am running the same code on my system, however it is giving the error "Subscript indices must either be real positive integers or logicals" where the code tries to match the similarity between the two images.

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);

I am new to MATLAB and just trying to understand the concepts however I got stuck in this. Any help is appreciated. Thank you.

1
I think it means the subscript indices are not positive integers or logicals. So I'd check to see if indexPairs(:,1) is an array of positive integers or logicals or something else. - David
The indexPairs is an array of 0's and positive numbers wherever it manages to find a match between the two images. - Crazy Cat
So is it an array of logicals (1's and 0's only) or numbers (all integers between 1 and the maximum size of the array you are indexing in to)? - David
It is an array of 0's and numbers pertaining to the indices location, so positive integers. - Crazy Cat
Well that's why you are getting an error. The indexes can be logicals OR integers, not both. - David

1 Answers

0
votes

I tried your code (with some slight changes) with a sample image and it worked:

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

I downloaded the sample image from: http://www.stereomaker.net/java/spva/img_0236.jpg