Comparing multiple images to a single image
Show older comments
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 Comment
KALYAN ACHARJYA
on 13 May 2018
Is your problem solved? The answer will perfectly work.
Answers (1)
KALYAN ACHARJYA
on 13 May 2018
Edited: KALYAN ACHARJYA
on 13 May 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 Comments
Nagalapalli Sudheer
on 18 Jul 2018
Edited: Nagalapalli Sudheer
on 18 Jul 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
on 30 Jul 2018
Is the problem sorted?
Sneha P
on 14 May 2022
can you please help iam also struggling with same problem
KALYAN ACHARJYA
on 15 May 2022
Edited: KALYAN ACHARJYA
on 15 May 2022
@Sneha P Please Share the detail?
KALYAN ACHARJYA
on 15 May 2022
@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);
KALYAN ACHARJYA
on 15 May 2022
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
Categories
Find more on ROI-Based Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!