aggregate bounding box area in an image

조회 수: 1 (최근 30일)
em
em 2014년 11월 11일
답변: Image Analyst 2014년 11월 11일
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.

답변 (1개)

Image Analyst
Image Analyst 2014년 11월 11일
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