aggregate bounding box area in an image

1 Ansicht (letzte 30 Tage)
em
em am 11 Nov. 2014
Beantwortet: Image Analyst am 11 Nov. 2014
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.

Antworten (1)

Image Analyst
Image Analyst am 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);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by