object recognition in image

I want to know if an object is in a image or not. So i took the contours of this object and also all the contours of objects that are in the other image. But now i would compare the econtour of my object and the contour of the other object. The problem is that the size/position are not the same between my object and the object in the picture. Could you help me on that ?
import de limage et mise en noir et blanc
logo=imread("logo.jpg");
picture = imresize(logo,[500,500]);
picture = rgb2gray(picture);
imshow(picture)
transformation en image binaire
for i= 1:500
for j = 1:500
if picture(i,j)>0
picture(i,j)=1;
end
end
end
imshow(picture,[0,1])
extraction des contours de limage de ref
% Extraction des contours de l'objet
contours_base = bwboundaries(picture);% Affichage de l'image binaire avec les contours
imshow(picture,[0,1])
hold on;
% Tracé des contours
for k = [2,280]
boundary_base = contours_base{k};
plot(boundary_base(:,2), boundary_base(:,1), 'r', 'LineWidth', 2);
end
hold off
import de l'image a test et enlevage de larriere plan
img=imresize(imread("logoreco.jpg"),[500,500]);
forme_image = imbinarize(rgb2gray(img),'adaptive','Sensitivity',0.7);
imshowpair(forme_image,img,'montage')
% Extraction des contours de l'objet
contours = bwboundaries(forme_image);% Affichage de l'image binaire avec les contours
imshow(forme_image,[0,1])
hold on;
% Tracé des contours
for k = 1:length(contours)
boundary = contours{k};
plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 2);
end
hold off
logo.jpg
logoreco.jpg

回答 (1 件)

Image Analyst
Image Analyst 2023 年 4 月 26 日

0 投票

Depends on your images and your target object. For widest range of how things look, you should investigate Deep Learning CNN classification.

3 件のコメント

julien
julien 2023 年 4 月 26 日
I think about deep learning but it s not allowed to solve the problem 🥲
Image Analyst
Image Analyst 2023 年 4 月 26 日
If the template is the same size you can use normalized cross correlation. See attached demo.
Or try Hu's moments:
Or this:
julien
julien 2023 年 4 月 29 日
Thank you a lot !
I tried the matlab file but it seems to not working in my case. It works when we crop in the original image but not when we take another image. The video seem interessant but I can t see the code. If you have any other idees to detect a special oject in an image I will be verry happy to test them.

サインインしてコメントする。

製品

リリース

R2022b

質問済み:

2023 年 4 月 26 日

コメント済み:

2023 年 4 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by