⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lhiobjectnames.m

📁 This code can parse any image in matlab. Very elaborate code
💻 M
字号:
function [names, counts, imagendx, objectndx, descriptionndx] = LHIobjectnames(D, field);
% Returns the name of all the object classes in the database, 
% and the number of instances of each object class:
%
% [names, counts] = LHIobjectnames(D);
%
% You can visualize the counts and object names by calling the function
% without output arguments:
%
% LHIobjectnames(D);
%
% You can see the list of words associated with an object class using the
% command LHIobjectnames. Some examples:
%   LHIobjectnames(LHIquery(D, 'name', 'face'))
%   LHIobjectnames(LHIquery(D, 'name', 'plate'))
%   LHIobjectnames(LHIquery(D, 'name', 'person'))
%
% [names, counts, imagendx, objectndx, descriptionndx] = LHIobjectnames(D);

if nargin == 1
    field = 'name';
end

Nannotations = length(D);
Npolygons = 20*Nannotations;

names = {};
imagendx = zeros(Npolygons,1); 
objectndx = zeros(Npolygons,1);

m = 0;

for i = 1:Nannotations
    if mod(i,100)==0; disp(i); end

    if isfield(D(i).annotation, 'object')
        if isfield(D(i).annotation.object, field)
            N = length(D(i).annotation.object);
            for j = 1:N
                %
                m = m+1;
                if length(D(i).annotation.object(j).(field))>0
                    names{m} = D(i).annotation.object(j).(field);
                else
                    names{m} = '';
                end
                imagendx(m) = i;
                objectndx(m) = j;
            end
        end
    end
end
imagendx = imagendx(1:m);
objectndx = objectndx(1:m);

[foo, i, descriptionndx] = unique(strtrim(lower(names)));
names = strtrim(names(i));

if nargout ~= 1 | nargin == 2
    Nobject = length(names);
    [counts, x] = hist(descriptionndx, 1:Nobject);
end


if nargout == 0
    % plot counts
    figure
    barh(counts)
    set(gca, 'YTick', 1:Nobject)
    set(gca, 'YtickLabel', names)
    axis([0 max(counts)+5 0 Nobject+1])
    grid on
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -