qNode *qtree_helper(unsigned char *depth_map, int map_width, int section_width, int x, int y) {
    
    qNode *root = (qNode *)malloc(sizeof(qNode));
    if(root==NULL)
    {
        allocation_failed();
    }

    root->x = x;
    root->y = y;
    root->size = section_width;
    int val = homogenous(depth_map, map_width, x, y, section_width);
    (*root).gray_value = val;

    if(val!=256)
    {
        (*root).leaf = 1;
        return root;
    }
    else
    {
        root->leaf = 0;
        root->child_NW = qtree_helper(depth_map, map_width, section_width/2, x, y);
        root->child_NE = qtree_helper(depth_map, map_width, section_width/2, x + (section_width/2), y);
        root->child_SW = qtree_helper(depth_map, map_width, section_width/2, x, y + (section_width/2));
        root->child_SE = qtree_helper(depth_map, map_width, section_width/2, x + (section_width/2), y + (section_width/2));
        return root;
    }

}
Exemplo n.º 2
0
qNode* depth_helper(unsigned char *depth_map, int map_width, int section_width, int x, int y) {
    
    qNode *node = (qNode*) malloc(sizeof(qNode));
    if (!(node)){
        allocation_failed();
    }

    int gray_value = homogenous(depth_map, map_width, x, y, section_width);
    node->gray_value = gray_value;
    node->size = section_width;
    node->x = x;
    node->y = y;

    if(gray_value == 256) {
        node->leaf = 0;

        node->child_NW = depth_helper(depth_map, map_width, .5 * section_width, x, y);
        node->child_NE = depth_helper(depth_map, map_width, .5 * section_width, x + (.5 * section_width), y);
        node->child_SE = depth_helper(depth_map, map_width, .5 * section_width, x + (.5 * section_width), y + (.5 * section_width));
        node->child_SW = depth_helper(depth_map, map_width, .5 * section_width, x, y + (.5 * section_width));
                        
    
    } else {
        node -> leaf = 1;
    }
    return node;
}
Exemplo n.º 3
0
qNode *recursive_quad(unsigned char *depth_map, int map_width, int x, int y, int section_width){
    qNode* node = malloc(sizeof(qNode));
    if (homogenous(depth_map, map_width, x, y, section_width) != 256){
        node->leaf = 1;
        node->size = section_width;
        node->x = x;
        node->y = y;
        node->gray_value = depth_map[y*map_width + x];
    }else{
        node->leaf = 0;
        node->size = section_width;
        node->x = x;
        node->y = y;
        node->gray_value = 256;
        section_width = section_width / 2;
        node->child_NW = recursive_quad(depth_map, map_width, x, y, section_width);
        node->child_NE = recursive_quad(depth_map, map_width, x + section_width, y, section_width);
        node->child_SE = recursive_quad(depth_map, map_width, x + section_width, y + section_width, section_width);
        node->child_SW = recursive_quad(depth_map, map_width, x, y+section_width, section_width);
    }
    return node;
}