Compare one image to folder which have multiple images
Mostrar comentarios más antiguos
I have a requirement to compare two images..
Input source an be either webcam/ image
compare source - a folder which has 15 images which is an extract from videos .
Code iam executing which i have picked from one FAQ source
% Specify the folder where the reference image file lives.
refFolder = 'C:\Users\Sneha\Desktop\MATLAB\video_extract'; % or wherever, such as 'C:\Users\yourUserName\Documents\My Pictures';
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isfolder(refFolder)
errorMessage = sprintf('Error: The following reference folder does not exist:\n%s', refFolder);
uiwait(warndlg(errorMessage));
return;
end
% Read in the reference image.
fullRefImageFileName = fullfile(refFolder, 'find_person2.jpg');
if ~exist(fullRefImageFileName, 'file')
errorMessage = sprintf('Error: The following reference image does not exist:\n%s', fullRefImageFileName);
uiwait(warndlg(errorMessage));
return;
else
refImage = imread(fullRefImageFileName);
end
% Specify the folder where the test image files live.
testFolder = 'C:\Users\Sneha\Desktop\MATLAB\video_extract\'; % or wherever, such as 'C:\Users\yourUserName\Documents\My Pictures';
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isfolder(testFolder)
errorMessage = sprintf('Error: The following test image folder does not exist:\n%s', testFolder);
uiwait(warndlg(errorMessage));
return;
end
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(testFolder, '*.jpg'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(testFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Read in test image.
testImage = imread(fullFileName);
imshow(testImage); % Display image.
drawnow; % Force display to update immediately.
% Now do whatever you want with this file name,
% such as comparing the image array with refImage in some function you write.
results = CompareImages(testImage, refImage);
end
results = CompareImages(testImage, refImage); --> This area getting an error
Unrecognized function or variable 'CompareImages'.
results = isequal(testImage, refImage); --> this is simply reading all images rather than comparing the tesimage(folder) and refimage(image given as imput source)
Respuestas (1)
Image Analyst
el 15 de Mayo de 2022
0 votos
Yes, we talked about this before. You need to write your own CompareImages function. It's not some generic function built in to MATLAB since there are thousands of ways to compare images. You'll just have to program up your own algorithm.
7 comentarios
Sneha P
el 15 de Mayo de 2022
Image Analyst
el 15 de Mayo de 2022
Surely you must know what you want to compare. Do you just want to return true if even one pixel is different than the two? Do you want to return the average intensity difference between the two? Again, surely you must have SOME idea, otherwise what is the point?
Sneha P
el 15 de Mayo de 2022
Image Analyst
el 15 de Mayo de 2022
So you want a facial recognition function. That's not trivial. That would take literally months of work. I'm not prepared to donate that much time to you. Sorry.
Go here to find functions where people have done it. Pick one and code it up:
If you need help, ask the Mathworks consulting department to write it for you.
Sneha P
el 15 de Mayo de 2022
Sneha P
el 15 de Mayo de 2022
Image Analyst
el 15 de Mayo de 2022
Did you try their home page, down at the bottom?
Here is the deep link:
Categorías
Más información sobre Computer Vision Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!