Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
2D cross correlation unable to match
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
HI,
i am trying to compare 2 images using corr2 . When i compare with the first image in the folder, an error message is prompt which is what i wanted. But when the 2nd image in the folder is used to compare, it states that there is no match. I am not sure where went wrong, the 2nd image is already in the folder and its exactly the same but there is no match.
% --- Executes on button press in btnSelectFolder.
function btnSelectFolder_Callback(hObject, eventdata, handles)
% hObject handle to btnSelectFolder (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.png;', 'All Image Files (*.png)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick an image file');
if filename ~= 0
FileName = fullfile(pathname,filename);
end
if pathname==0,
return;
end
axes (handles.axes1);
queryFace= imread (FileName);
queryFaceresize=imresize(queryFace,[240,240]);
imshow(queryFaceresize, 'Parent', handles.axes1);
faceDetector=vision.CascadeObjectDetector('FrontalFaceCART');
bbox = step(faceDetector,queryFace);
axes (handles.axes1);
if size(bbox,1) == 0
errordlg('No face detected.Please upload another one.');
return;
elseif size(bbox,1)>1
errordlg('Too many face detected. Please upload another one')
return;
else
path='C:\Users\ET\Desktop\matlab\project\Database\';
list=dir([path, '*.png']);
img=imread(FileName);
newimg=imresize(img,[240 240]);
X1=rgb2ind(newimg,16);
for x=1:length(list)
images{x}=imread([path, list(x).name]);
X2=rgb2ind(images{x},16);
newX2=imresize(X2,size(X1));
c=corr2(X1,newX2);
if c==1
errordlg('Image Error. Please upload another one');
return;
else
msgbox('Please click the save button to save your image into our system.');
set(handles.saveImage,'Visible','on');
return;
end
end
end
please help!
thank you!
1 commentaire
Geoff Hayes
le 29 Mar 2015
Eliza - put a breakpoint at the line
for x=1:length(list)
and then run your code. When the debugger pauses at this line, start stepping through the code and look at each variable to ensure that it makes sense. What are X1 and newX2? Display each image using imshow to see each one. After the correlation, what is c?
Réponses (1)
Image Analyst
le 29 Mar 2015
Perhaps you really meant to use normxcorr2(). See attached demo.

0 commentaires
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!