Comparing multiple images to a single image

I want to compare a single image with multiple images that i have stored in a folder with the name of 1.bmp, 2.bmp,... 45.bmp. I want to compare a single image which i am capturing from the camera with these images from the folder. How do i compare this one image with these multiple images? (I thought of using the for loop but i don't know how to use it with images)
Any help will be appreciated. Thank You

1 comentario

KALYAN ACHARJYA
KALYAN ACHARJYA el 13 de Mayo de 2018
Is your problem solved? The answer will perfectly work.

Iniciar sesión para comentar.

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 13 de Mayo de 2018
Editada: KALYAN ACHARJYA el 13 de Mayo de 2018
% code
% Save all images name in a sequence manner before doing the operation
% names for example im1,im2,im3..or 1,2,3...so on
%Save the folder of images in the current directory
Image=capture from camera % do this operation
path_directory='folder_name'; % 'Folder name'
original_files=dir([path_directory '/*.bmp']);
for k=1:length(original_files)
filename=[path_directory '/' original_files(k).name];
image_call=imread(filename);
% Image call is done
%Now compare Image and Image_call and do rest operation
end

6 comentarios

Nagalapalli Sudheer
Nagalapalli Sudheer el 18 de Jul. de 2018
Editada: Nagalapalli Sudheer el 18 de Jul. de 2018
srcFiles = dir('E:\ibps\img\1\*.bmp'); image_1=length(srcFiles); srcFiles2 = dir('E:\ibps\img\2\*.bmp'); image_2=length(srcFiles2); for i = 1:image_1 aa = strcat('E:\ibps\img\',srcFiles(i).name); a = imread(aa); %first img for j=1:image_2 bb = strcat('E:\ibps\img\',srcFiles2(j).name); b = imread(bb); %second img a = rgb2ind(a,16); b = rgb2ind(b,16); c = corr2(a,b); %finding the correlation if c==1 disp('The images are same') % display else disp('the images are not same') end end end
i have stored some 15 images in one folder and want to compare each image with other and to see that images r same or not,but i am not getting anything just it is showing the name of the file which i saved can you help plz
KALYAN ACHARJYA
KALYAN ACHARJYA el 30 de Jul. de 2018
Is the problem sorted?
Sneha P
Sneha P el 14 de Mayo de 2022
can you please help iam also struggling with same problem
KALYAN ACHARJYA
KALYAN ACHARJYA el 15 de Mayo de 2022
Editada: KALYAN ACHARJYA el 15 de Mayo de 2022
@Sneha P Please Share the detail?
@Sneha P comments posted here (removed from answer section)
srcFiles = dir('C:\Users\Sneha\Desktop\MATLAB\video_extract\*.jpg');
image_1=length(srcFiles);
srcFiles2 = dir('C:\Users\Sneha\Desktop\MATLAB\video_extract\*.jpg');
image_2=length(srcFiles2);
for i = 1:image_1
aa = strcat('C:\Users\Sneha\Desktop\MATLAB\video_extract\',srcFiles(i).name);
a = imread(aa); %first img
for j=1:image_2
bb = strcat('C:\Users\Sneha\Desktop\MATLAB\video_extract\',srcFiles2(j).name);
b = imread(bb); %second img
a = rgb2ind(a,16);
b = rgb2ind(b,16);
c = corr2(a,b); %finding the correlation
if c==1
disp('The images are same') % display
else
disp('the images are not same')
end
end
end
ERROR
The images are same
Error using matlab.images.internal.cq
First input must be a 3-D uint8 array.
Error in rgb2ind (line 93)
[map,X] = matlab.images.internal.cq(RGB,m);
More:
% Save all images name in a sequence manner before doing the operation
% names for example im1,im2,im3..or 1,2,3...so on
%Save the folder of images in the current directory
Image=webcam(); % do this operation
path_directory='C:\Users\Sneha\Desktop\MATLAB\video_extract'; % 'Folder name'
original_files=dir([path_directory '/*.jpg']);
for k=1:length(original_files)
filename=[path_directory '/' original_files(k).name];
image_call=imread(filename);
% Image call is done
%Now compare Image and Image_call and do rest operation
end
%Now compare Image and Image_call and do rest operation --> I need help on how to do the image compare

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 13 de Mayo de 2018

Comentada:

el 15 de Mayo de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by