Effacer les filtres
Effacer les filtres

Compare one image to folder which have multiple images

5 vues (au cours des 30 derniers jours)
Sneha P
Sneha P le 15 Mai 2022
Commenté : Image Analyst le 15 Mai 2022
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)

Réponses (1)

Image Analyst
Image Analyst le 15 Mai 2022
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 commentaires
Sneha P
Sneha P le 15 Mai 2022
How to contact mathwork consulting department
Image Analyst
Image Analyst le 15 Mai 2022
Did you try their home page, down at the bottom?
Here is the deep link:

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Processing and Computer Vision dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by