how to draw a BoundingBox
Mostrar comentarios más antiguos
Hello. Can someone help me please ? I'm just starting in programation. I found a code that can detect edges, and i want to draw a bounding boxes arround the detected edges.
if true
close all;clear all;clc
vid = VideoReader ('F:\TRAIT IMG\DETECTION\vol_drone.mp4');
k = vid.NumberOfFrames;
for i=1:k
J=read(vid,i);
%imshow(rgb2gray(J));
%J = imread('drone.jpg');
I = rgb2gray(J);
% imshow(I), title('image original grisé');
[~, threshold] = edge(I, 'sobel');
fudgeFactor = .5;
BWs = edge(I,'sobel', threshold * fudgeFactor);
figure, imshow(BWs), title('binary gradient mask');
se90 = strel('line', 3, 90);
se0 = strel('line', 3, 0);
BWsdil = imdilate(BWs, [se90 se0]);
figure, imshow(BWsdil), title('dilated gradient mask');
BWdfill = imfill(BWsdil, 'holes');
figure, imshow(BWdfill);
title('binary image with filled holes');
BWnobord = imclearborder(BWdfill, 4);
figure, imshow(BWnobord), title('cleared border image');
seD = strel('diamond',1);
BWfinal = imerode(BWnobord,seD);
BWfinal = imerode(BWfinal,seD);
figure, imshow(BWfinal), title('segmented image');
BWoutline = bwperim(BWfinal);
Segout = J;
Segout(BWoutline) = 255;
figure,
imshow(Segout), title('outlined original image');
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!