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

Is your problem solved? The answer will perfectly work.

댓글을 달려면 로그인하십시오.

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 5월 13일
편집: KALYAN ACHARJYA 2018년 5월 13일

2 개 추천

% 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

Nagalapalli Sudheer
Nagalapalli Sudheer 2018년 7월 18일
편집: Nagalapalli Sudheer 2018년 7월 18일
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
Is the problem sorted?
Sneha P
Sneha P 2022년 5월 14일
can you please help iam also struggling with same problem
KALYAN ACHARJYA
KALYAN ACHARJYA 2022년 5월 15일
편집: KALYAN ACHARJYA 2022년 5월 15일
@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

댓글을 달려면 로그인하십시오.

질문:

2018년 5월 13일

댓글:

2022년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by