aggregate bounding box area in an image
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an image I, and a set of bounding box positions in a matrix A, A=[x10 y10 x11 y11; x20 y20 x21 y21...xn0 yn0 xn1 yn1]. Those boxes can be visualized on the image like below.
imshow(I);
numparts = floor(size(A, 2)/4);
for i = 1:numparts
x1 = A(1,1+(i-1)*4);
y1 = A(1,2+(i-1)*4);
x2 = A(1,3+(i-1)*4);
y2 = A(1,4+(i-1)*4);
line([x1 x1 x2 x2 x1]',[y1 y2 y2 y1 y1]','color',colorset{i},'linewidth',2);
end

How can I aggregate those bounding box areas, so that pixels in the those boxes are labeled as 1, otherwise labeled as 0? I don't want an all-inclusive bounding box which includes all bounding boxes in A. I need a more precise area map which aggregates bounding boxes in A.
0 commentaires
Réponses (1)
Image Analyst
le 11 Nov 2014
Maybe this:
[rows, columns, numberOfColorChannels] = size(I);
binaryImage = false(rows, columns);
for i = 1:numparts
x1 = A(1,1+(i-1)*4);
y1 = A(1,2+(i-1)*4);
x2 = A(1,3+(i-1)*4);
y2 = A(1,4+(i-1)*4);
line([x1 x1 x2 x2 x1]',[y1 y2 y2 y1 y1]','color',colorset{i},'linewidth',2);
binaryImage(y1:y2, x1:x2) = true;
end
imshow(binaryImage);
0 commentaires
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!