0

I have to extract features of an image using the image extraction from MATLAB. It works successfully with the image provided by The MathWorks in their tutorial, but when I enter another image it doesn't work

My code for image extraction is:

boxImage = imread('stapleRemover.jpg');
%boxImage = imread('D:\matlab test\book\IMG_2294.jpg');

figure;
imshow(boxImage);
title('Image of a Box');

%sceneImage = imread('D:\matlab test\book\IMG_2291.jpg');
sceneImage = imread('clutteredDesk.jpg');
figure;
imshow(sceneImage);
title('Image of Cluttered Scene');

%detecting feature point
boxPoints = detectSURFFeatures(boxImage);
scenePoints = detectSURFFeatures(sceneImage);

figure;
imshow(boxImage);
title('100 strongest feature Points from Box Image');
hold on;
plot(selectStrongest(boxPoints, 100));

figure;
imshow(sceneImage);
title('300 Strongest Feature Points from Scene Image');
hold on;
plot(selectStrongest(scenePoints, 300));

%extracting feature descriptor
[boxFeatures, boxPoints] = extractFeatures(boxImage, boxPoints);
[sceneFeatures, scenePoints] = extractFeatures(sceneImage, scenePoints);

%finding putative point match
boxPairs = matchFeatures(boxFeatures, sceneFeatures);

matchedBoxPoints = boxPoints(boxPairs(:, 1), :);
matchedScenePoints = scenePoints(boxPairs(:, 2), :);
figure;
showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints, matchedScenePoints, 'montage');
title('Putatively Matched Points (Including Outliers)');

%locating object in the scene using putative matches
[tform, inlierBoxPoints, inlierScenePoints] =  estimateGeometricTransform(matchedBoxPoints, matchedScenePoints, 'affine');

figure;
showMatchedFeatures(boxImage, sceneImage, inlierBoxPoints,inlierScenePoints, 'montage');
title('Matched Points (Inliers Only)');

boxPolygon = [1, 1;                          % top-left
        size(boxImage, 2), 1;                 % top-right
        size(boxImage, 2), size(boxImage, 1); % bottom-right
        1, size(boxImage, 1);                 % bottom-left
        1, 1];                   % top-left again to close the polygon

    newBoxPolygon = transformPointsForward(tform, boxPolygon);

    figure;
    imshow(boxPolygon);
imshow(sceneImage);
hold on;
line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y');
title('Detected Box');

It runs successfully, but when I change the image which is made by me using my camera, it stops executing code on this line:

boxPoints = detectSURFFeatures(boxImage);

Can anyone help me to out?

Adriaan
  • 17,741
  • 7
  • 42
  • 75
hardik
  • 378
  • 5
  • 18

2 Answers2

0

What error are you getting? From the information you've given, I would guess that your image is RGB, and you need to convert it to grayscale before passing it to detectSURFFeatures.

Dima
  • 38,860
  • 14
  • 75
  • 115
  • but my problem is solved the problem was my image was rgb image so i convert it into grayscale image and my problem was solved – hardik Mar 24 '15 at 15:38
0

Undefined function showMatchedFeatures for input arguments of type SURFPoints. in matlab 2012a

Robert
  • 5,278
  • 43
  • 65
  • 115