tmp_disp_stat.m

来自「This code can parse any image in matlab.」· M 代码 · 共 85 行

M
85
字号
frequency = sum(instancecounts,2);
[ff, ndx] = sort(frequency,'descend');

% sort by frequency:
instancecounts = instancecounts(ndx, :);
objectnamesSort = objectnames(ndx);

% Show object counts sorted by frequency
handle=figure; maximize(handle);
imagesc(instancecounts)
colormap(gray(256))
set(gca, 'YTick', 1:size(positions,1))
set(gca, 'YtickLabel', objectnamesSort)
ylabel('Object index')
xlabel('Image index')
title('Each entry counts the number of times the object y is in the image x')
axis('on')
axis('tight')

layout = [6 6]; offset = 0;
positions = positions(ndx, :, :);
handle=figure; maximize(handle);
for i=1:size(positions,1)
    subplot(layout(1),layout(2),i-offset);
    mask = logical(zeros(64,64));
    for j=1:size(positions,2)
       if (positions(i,j,1) == 0 || positions(i,j,2) == 0)
           continue;
       end
       mask(ceil(64*positions(i,j,2)),ceil(64*positions(i,j,1)))= 1;
    end
    imshow(logical(mask),[]);
    xlabel('X pos'); ylabel('Y pos');
    title(objectnamesSort{i});
    if (rem(i,layout(1)*layout(2)) == 0)
        handle=figure; maximize(handle);
        offset = offset + layout(1)*layout(2);
    end
end

%sort by point number
pointnum = sum(pointcounts,2);
[ff, ndx] = sort(pointnum,'descend');

pointcounts = pointcounts(ndx, :);
objectnamesSort = objectnames(ndx);
offset = 0;
handle=figure; maximize(handle);
for i=1:size(pointcounts,1)
    subplot(layout(1),layout(2),i-offset);
    %remove 0
    bins = pointcounts(i,:);
    bins = bins(bins>0);
    hist(bins); axis normal;
    ylabel('boundary points');
    title(objectnamesSort{i});
    if (rem(i,layout(1)*layout(2)) == 0)
        handle=figure; maximize(handle);
        offset = offset + layout(1)*layout(2);
    end
end

%sort by area number
areasum = sum(areacounts,2);
[ff, ndx] = sort(areasum,'descend');

areacounts = areacounts(ndx, :);
objectnamesSort = objectnames(ndx);
handle=figure; maximize(handle);
offset = 0;
for i=1:size(areacounts,1)
    subplot(layout(1),layout(2),i-offset);
    bins = areacounts(i,:);
    bins = bins(bins>0);
    hist(bins); axis('normal');
    h = findobj(gca,'Type','patch');
    set(h,'FaceColor','r','EdgeColor','w')
    ylabel('Area percent');
    
    title(objectnamesSort{i});
    if (rem(i,layout(1)*layout(2)) == 0)
        handle=figure; maximize(handle);
        offset = offset + layout(1)*layout(2);
    end
end

⌨️ 快捷键说明

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