object recognition in image

3 views (last 30 days)
julien
julien on 26 Apr 2023
Commented: julien on 29 Apr 2023
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

Answers (1)

Image Analyst
Image Analyst on 26 Apr 2023
Depends on your images and your target object. For widest range of how things look, you should investigate Deep Learning CNN classification.
  3 Comments
julien
julien on 29 Apr 2023
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.

Sign in to comment.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!