bounding box around canny edge detecter
Afficher commentaires plus anciens
i have detected edges using canny edge detecter now i want to make a bounding box around the object to detect it how can i do that i have used the below code to make a bounding box but it just changes the color of the edges not making a bounding box
if true
% %this program will make a yellow clour on edges
% [B,L] = bwboundaries(F, 'noholes');
% figure; imshow(F); hold on;
% for k = 1:length(B),
% boundary = B{k};
% plot(boundary(:,2),boundary(:,1),'w','LineWidth',2);
% end
end
Réponses (1)
Image Analyst
le 25 Nov 2016
To get bounding boxes, you'll either have to use regionprops, or use max and min on the x and y vectors:
x = boundary(:,2);
y = boundary(:,1);
x1 = min(x);
x2 = max(x);
y1 = min(y);
y2 = max(y);
xBox = [x1, x2, x2, x1, x1];
yBox = [y1, y1, y2, y2, y1];
% Plot boundary
plot(x, y, 'm-', 'LineWidth' ,2);
% Plot bounding box.
hold on;
plot(xBox, yBox, 'y-', 'LineWidth' ,2);
2 commentaires
ahmed SHAH
le 27 Nov 2016
Modifié(e) : Image Analyst
le 27 Nov 2016
Image Analyst
le 27 Nov 2016
Modifié(e) : Image Analyst
le 27 Nov 2016
Evidently you have some edges out there at the boundary of the image. You'll need to get rid of those. Maybe it's because you, for some reason, inverted the edge image before computing boundaries. I never would have done that. Attach your original image so I can try it. By the way, why even do edge detection? Can't you get the object by simple thresholding?
Catégories
En savoir plus sur Object Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
