error

5 次查看(过去 30 天)
Preetam Sundaray
Preetam Sundaray 2012-6-11
Finding keypoints... 3809 keypoints found. Warning: Function D:\siftDemoV4\image.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict. > In sift at 48 In abcd at 2 Drawing SIFT keypoints ... ??? Error using ==> image Too many input arguments.
Error in ==> imagesc at 19 hh = image(varargin{1},'CDataMapping','scaled');
Error in ==> showkeys at 16 imagesc(image);
Error in ==> abcd at 3 showkeys(im1,loc1);
I AM GETTING THESE ERRORS WHILE RUNNING THE FOLLOWING MATLAB CODE
function num=match(im1,im2)
[im1,des1,loc1]=sift('mm.pgm');
showkeys(im1,loc1);
[im2,des2,loc2]=sift('nn.pgm');
showkeys(im2,loc2);
distRatio=0.6;
des2t =des2';
for i = 1 : size(des1,1)
dotprods = des1(i,:) * des2t;
[vals,indx] = sort(acos(dotprods));
if (vals(1) < distRatio * vals(2))
match(i) = indx(1);
else
match(i) = 0;
end
end
im3 = appendimages(im1,im2);
figure('Position', [100 100 size(im3,2) size(im3,1)]);
colormap('gray');
imagesc(im3);
hold on;
cols1 = size(im1,2);
for i = 1: size(des1,1)
if (match(i) > 0)
line([loc1(i,2) loc2(match(i),2)+cols1], ...
[loc1(i,1) loc2(match(i),1)], 'Color', 'c');
end
end
hold off
num = sum(match >0);
fprintf('Found %d matches.\n', num);
HELP ME PLEASE

回答(2 个)

DGM
DGM 2024-6-4
We know the following:
  1. You get a warning that a specific user-created (or downloaded) filename is preventing the use of a builtin function.
  2. Then you try to use said builtin function, and it results in an error.
These two things are directly related. The warning literally tells you which file is at fault and what to do in order to to fix it. Be careful when naming files and variables so that you don't shadow functions you might need. Sometimes it's an easy mistake to make if you aren't familiar with a lot of function names, but it should be an easy mistake to catch and fix if you pay attention to the information that warnings and errors provide.

Image Analyst
Image Analyst 2024-6-4
The main problem is exactly what it said and that is your script is called image.m which will take priority over a very important built-in function called image. Never do that. Call your script something else, like test_sift.m or something.
You gave us code for neither abcd.m, nor showkeys(), so how can we help you? Please attach them and any needed image(s) so I can run your code. You .pgm files may need to be put into a .zip file before attaching.
Why are you passing in im1 and im2 into match() when you immediately overwrite them with a call to sift()????
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by