0

ユーザーから画像の名前を取得し、それを既存の画像と比較して、一致するかどうかを表示できるようにするmatlab関数を作成しました。

function matchin
handles = guidata(gcbo);
set(handles.h_text,'String','performing matching...');
[image1, pathname]= uigetfile('*.bmp','Open An Fingerprint image');
Directory = fullfile ('F:','matlab','bin');
D = dir(fullfile(Directory,'*.bmp'));
set(handles.h_text,'String','matching complete....');
for i = 1:numel(D)
   if strcmp(image1,D(i).name)
       disp('matched');
   else       
        disp('not matched');
   end

end

上記のコードはファイル名が存在するかどうかをチェックしますが、ファイル名の代わりに画像自体を比較したいと思います。どうすればいいですか?助けてください。

よろしく

プリヤ

4

2 に答える 2

1

Your function should be something like this:

function image1=matchin

[image1, pathname]= uigetfile('*.bmp','Open An Fingerprint image');
Directory = fullfile ('F:','matlab','bin');
D = dir(fullfile(Directory,'*.bmp'));
imcell = {D.name}';
for i = 1:numel(D)
  if strcmp(image1,imcell{i})
  disp('matched');
else
    disp('not matched');
  end
end

end

you get the name of every file using {D.name}'. That's how it works for me at least when I tried it in a folder with images.

于 2013-03-20T15:45:47.257 に答える
1

strcmpの代わりに、==長さが不明な文字列を比較するために使用します。次のように変更できますfor loop

D = dir(Directory);
for i = 1:numel(D)
   if strcmp(image1,D(i).name)
       disp('matched');
   else
       disp('not matched');
   end
end
于 2013-03-20T15:33:24.980 に答える