Beispiel #1
0
def ground_truth_region_ids(regions, ground_truth, min_size=0):
    sizes = region_sizes_img(regions)
    region_ids = []
    for i, x in enumerate(sizes):
        if x > min_size:
            if not ground_truth is None:
                try:
                    segments.get_class_distribution(ground_truth, regions == i)
                    region_ids.append(i)
                except UserWarning:
                    continue
            else:
                region_ids.append(i)
    return region_ids
Beispiel #2
0
def ground_truth_region_ids(regions, ground_truth, min_size=0):
    sizes = region_sizes_img(regions)
    region_ids = []
    for i, x in enumerate(sizes):
        if x > min_size:
            if not ground_truth is None:
                try:
                    segments.get_class_distribution(ground_truth, regions == i)
                    region_ids.append(i)
                except UserWarning:
                    continue
            else:
                region_ids.append(i)
    return region_ids
Beispiel #3
0
def create_regions_segments_struct(regions, masks, min_size=0, ground_truth=None):
    """produces a dict that maps region id to a list of segment ids
        if min_size is provided, only those regions that are bigger than that size are considered
        if ground_truth is given, then only regions are considered, that are not completely within an unlabeled area
    """
    sizes = region_sizes_img(regions)
    region_ids = []
    for i, x in enumerate(sizes):
        if x > min_size:
            if not ground_truth is None:
                try:
                    segments.get_class_distribution(ground_truth, regions == i)
                    region_ids.append(i)
                except UserWarning:
                    continue
            else:
                region_ids.append(i)
    
    rs = get_all_segments(region_ids, regions, masks)
    return dict(zip(region_ids, rs))
Beispiel #4
0
def create_regions_segments_struct(regions,
                                   masks,
                                   min_size=0,
                                   ground_truth=None):
    """produces a dict that maps region id to a list of segment ids
        if min_size is provided, only those regions that are bigger than that size are considered
        if ground_truth is given, then only regions are considered, that are not completely within an unlabeled area
    """
    sizes = region_sizes_img(regions)
    region_ids = []
    for i, x in enumerate(sizes):
        if x > min_size:
            if not ground_truth is None:
                try:
                    segments.get_class_distribution(ground_truth, regions == i)
                    region_ids.append(i)
                except UserWarning:
                    continue
            else:
                region_ids.append(i)

    rs = get_all_segments(region_ids, regions, masks)
    return dict(zip(region_ids, rs))