File size: 1,221 Bytes
d4035c1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
function boundingbox = LMobjectboundingbox(annotation, name)
% boundingbox = LMobjectboundingbox(annotation, name) returns all the bounding boxes that
% belong to object class 'name'. Is it an array Ninstances*4
%
% boundingbox = [xmin ymin xmax ymax]
% [x,y,jc] = LMobjectpolygon(annotation, varargin{:});
%
% Nobjects = length(x);
% if Nobjects == 0
% boundingbox = [];
% else
% boundingbox = zeros(Nobjects,4);
% for n = 1:Nobjects
% %[xn yn] = getLMpolygon(annotation.object(jc(n)).polygon);
% boundingbox(n,:) = [min(x{n}) min(y{n}) max(x{n}) max(y{n})];
% end
% end
if isfield(annotation, 'object')
if nargin == 1
jc = 1:length(annotation.object);
else
if ischar(name)
jc = LMobjectindex(annotation, name);
else
jc = name;
end
end
Nobjects = length(jc);
if Nobjects == 0
boundingbox = [];
else
boundingbox = zeros(Nobjects,4);
for n = 1:Nobjects
[x,y] = getLMpolygon(annotation.object(jc(n)).polygon);
boundingbox(n,:) = [min(x) min(y) max(x) max(y)];
end
end
else
x = [];
y = [];
t =[];
key = [];
jc = [];
end
|