object recognition in image
3 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
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
Image Analyst
on 26 Apr 2023
If the template is the same size you can use normalized cross correlation. See attached demo.
Or try Hu's moments:
Or this:
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!