fn_make_tree_structure

[tree_struc, tree_struc_detail, tree_info] = fn_make_tree_structure(superpixel_out_cell,level_list,option)

The function fn_make_tree_structure takes as input the field of superpixel indices and the level id of superpixel field, then outputs the tree structure created from the levels of interest controlled by the option.

Output

tree_struc: A 1 x N_total structure array, where N_total denotes the total number of nodes in the network; both hidden and evidence. tree_struc contains the information about the connectivities of the network. There are three fields:

  • node_id: the ID of each (child) node in the network
  • parent: corresponding parent for each of the child node in node_id
  • type: the type of each child node
    • hidden node (either for discrete or continuous) is denoted by 0
    • superpixel-level evidence node is denoted by 1
    • pixel-level evidence node is denoted by 2

It is convenient to say that the child node tree_struc(j).node_id of type tree_struc(j).type connects to its parent tree_struc(j).parent.

tree_struc_detail: A 1 x N_total_hid_level structure array, where N_total_hid_level denotes the total number of hidden level from root to leaf in the network. The array contains information about the node indices and their number in each level. The field names are as follows:

  • org_supx_idx: a row vector representing a list of superpixel indices in a particular level before made to node indices, therefore the index will always start from 1 to # of superpixel in the level without skipping.
  • node_idx: a row vector representing a list of node indices in a particular level after made into node indices, therefore, the smallest index of a particular level would be greater than the biggest index of the upper level by 1. Similarly, there is no skip in the indices.
  • N_supx: The number of superpixels/nodes in a particular level
  • offset: The number needed to be added to the superpixel indices in order to convert to node indices. It is convenient to say A(l).node_idx = A(l).org_supx_idx + offset
  • idx_field: The field of superpixel indices, from 1 to # of superpixel, in a particular level. Therefore, in order to convert the superpixel index field to node index field, we have to add the offset, for instance,
    • node_idx_field = supx_idx_field + (supx_idx_field~=0)*offset;
  • type: the type of each level. Note that every node in the same level shares the same type. Note we don't have the information which node is hidden or observed, but we have only the information that the level is superpixel or pixel.
    • superpixel-level evidence node is denoted by 1
    • pixel-level evidence node is denoted by 2
  • centroid: The row-column locations of the centers of each superpixel and pixel. The first and the second column represent row and column respectively.

tree_info: A structure containing the information about the overview of the tree including the indices and number of hidden and evidence nodes and the total number of the levels. The field names are

  • hidden_idx: List of hidden node indices
  • evidence_idx: List of evidence node indices
  • N_hidden: Total number of hidden nodes
  • N_evidence: Total number of evidence nodes
  • N_total_hid_level: Total number of hidden level from root to leaf

Input

superpixel_out_cell: A (1 x # of superpixel scales) cell array each of whose level contains superpixel indices running from 1 to the # of superpixel in the level. The cell array can have as many level as needed, and we might not use all of them though. In fact, this is the output of the function fn_make_superpixel, so for more details please refer to the function page directly.

level_list: The list of level indices in superpixel_out_cell we are interested to build a tree from.

For instance, if superpixel_out_cell was build from the N_sup list

N_sup = [3 5 10 20 30 50 60 80 100 120 140 150 180 200 220 250];

hence, there will be 16 levels of superpixel available, and let's assume building a tree from parameters

option = {};

option.N_set = 0.01;

option.single_root = 1;

option.px_level = 1;

level_list = [4 8 14];

[tree_struc, tree_struc_detail, tree_info] = fn_make_tree_structure(superpixel_out_cell,level_list,option);

It would mean we will have 5 hidden-node levels

level#5 "root" containing 1 node because of option.single_root = 1;

level#4 having 20 nodes, coming from the 4th number in the superpixel list in N_sup.

level#3 having 80 nodes, coming from the 8th number in the superpixel list in N_sup.

level#2 having 200 nodes, coming from the 14th number in the superpixel list in N_sup.

level#1 "pixel-level" containing large amount of nodes depending on the sampling rate option.N_set = 0.01 which means randomly sampling 1% of pixels in a superpixel and because of option.px_level = 1;

There are several options to direct the function.

Add the single root node at the top level and add the pixel level at the bottom

option.single_root = 1;

option.px_level = 1;

The result may looks like the top-left figure, in which there are 5 levels, the top level (l=5) is the single root determined by option.single_root = 1. Level 2-5 are all superpixel nodes, but the bottom most level (l=1) is pixel level determined by option.px_level = 1. Note that only hidden nodes are plotted in this figure.

option.single_root = 1

option.single_root = 0

option.px_level= 1

option.px_level= 0

Note

  1. this function can run on any type of superpixel regardless of how many levels or how many pixels per a level, so we can make TSBN from this function too.
  2. We always regard the bottom most hidden level as level l = 1 and keep increasing to the top. We also assign the level of evidence nodes the same as their parents (for now).