1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| %On charge l'image
img = myjpgload('~/IVR/assessment/map.jpeg',0);
% On la transcrit en image binaire par seuil
BW = imageprocess(img,52);
[W,L] = size(BW);
% Sobel pour detection des contours
BW = edge(BW,'sobel' );
BW = imfill(BW,'holes');
% Recuperation des contours
B = bwboundaries(BW);
nb_f = size(B,1);
fig=figure(1);
set(fig,'units','pixels','position',[50 50 750 500]);
imshow(BW);
% Ici on applique les contours autour des formes detectees
% sur la MEME figure ou l'image a ete affichee
hold on;
for k=1:nb_f
plot(B{k}(:,2),B{k}(:,1),'b','LineWidth',5);
end
hold off;
set(gca,'units','pixels','visible','off','position',[1 1 640 480]);
Frame = getframe(gca);
figure(2);
imshow(Frame.cdata); |
Partager