[mmmaxgetindex] [Up] [mmmaxgetchildren] Introspection Functions

mmmaxgetnodes
Returns node properties.

Synopsis

function y = mmmaxgetnodes ( maxtree , level , index )

Input

maxtree MaxTree The MaxTree.
level Double Node level.
index Double

Default: -1

Node index. If not specified or negative, the function returns properties for all nodes in the given level.

Output

y Image Properties of the node(s). Each row contains the following properties:
  • [0] isleaf: is this a leaf node?
  • [1] level: parent node level
  • [2] index: parent node index
  • [3] area: node area (number of pixels)
  • [4] sum_x: x_centroid = sum_x / area
  • [5] sum_y: y_centroid = sum_y / area
  • [6] xmin: minimum x coordinate
  • [7] ymin: minimum y coordinate
  • [8] xmax: maximum x coordinate
  • [9] ymax: maximum y coordinate
  • [10] height: node height
  • [11] volume: node volume

Description

This function returns the properties of the given node, if index is specified, or the properties for all nodes in a given level, if index is not specified or is negative.

Call mmmaxgetcount before this function to avoid accessing inexistent nodes.

Examples

a = uint8([1 2 3 4 4 4 3 2 3 5 6 6 4 4 4 3 3 4 1 2 2]);
mt = mmmaxtree(a);
nn = mmmaxgetcount(mt);
nlev = size(nn,1);
for i = 1:nlev
    if nn(i) > 0
        fprintf(1, '------------------------------\n');
        fprintf(1, 'Level: %d\n', i-1);
        nodes = double(mmmaxgetnodes(mt, i-1));
        for j = 1:size(nodes, 2)
            isleaf = nodes(1,j);
            plevel = nodes(2,j);
            pindex = nodes(3,j);
            area   = nodes(4,j);
            xx     = nodes(5,j);
            yy     = nodes(6,j);
            x0     = nodes(7,j);
            y0     = nodes(8,j);
            x1     = nodes(9,j);
            y1     = nodes(10,j);
            hh     = nodes(11,j);
            vv     = nodes(12,j);
            fprintf(1, '    -\n')
            fprintf(1, '    isleaf:       %d\n', isleaf)
            fprintf(1, '    parent level: %d\n', plevel)
            fprintf(1, '    parent index: %d\n', pindex)
            fprintf(1, '    area:         %d\n', area)
            fprintf(1, '    height:       %d\n', hh)
            fprintf(1, '    volume:       %d\n', vv)
            fprintf(1, '    centroid:     (%3.1f,%3.1f)\n', xx/area, yy/area)
            fprintf(1, '    bounding box: (%d,%d) - (%d,%d)\n', x0, y0, x1, y1)
        end
    end
end

[mmmaxgetindex] [Up] [mmmaxgetchildren]