我必须使用MATLAB中的图像提取来提取图像的特征。它可以成功地使用The MathWorks在他们的教程中提供的图像,但是当我输入另一个图像时它不起作用
我的图像提取代码是:
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');
它成功运行,但当我更改我使用相机拍摄的图像时,它会停止在此行上执行代码:
boxPoints = detectSURFFeatures(boxImage);
任何人都可以帮我出去吗?
答案 0 :(得分:0)
你得到什么错误?根据您提供的信息,我猜您的图像是RGB,您需要将其转换为灰度,然后再将其传递给detectSURFFeatures。
答案 1 :(得分:0)
未定义的函数showMatchedFeatures
对于SURFPoints
类型的输入参数。
在matlab 2012a