Ejemplo n.º 1
0
            offset_labels(Z, seg_idx, labels, this_slice_offset)
            this_slice_offset += numregions
            total_regions += numregions
        condensed_count = condense_labels(Z, numsegs, labels)
        print "Labeling depth %d: original %d, condensed %d" % (Z, this_slice_offset, condensed_count)
        for seg_idx in range (numsegs):
            offset_labels(Z, seg_idx, labels, cross_Z_offset)
        cross_Z_offset += condensed_count
        # XXX - apply cross-D offset
    print "Labeling took", int(time.time() - st), "seconds, ", condense_labels.total_time, "in condensing"
    print cross_Z_offset, "total labels", total_regions, "before condensing"

    if DEBUG:
        assert np.max(labels) == cross_Z_offset

    areas, exclusions, links = overlaps.count_overlaps_exclusionsets(numslices, numsegs, labels, link_worth)
    num_segments = len(areas)
    assert num_segments == cross_Z_offset + 1  # areas includes an area for 0

    st = time.time()
    model, links_to_segs = build_model(areas, exclusions, links)
    print "Building MILP took", int(time.time() - st), "seconds"

    # free memory
    areas = exclusions = links = None
    gc.collect()

    print "Solving"
    model.solve()
    print "Solving took", int(time.time() - st), "seconds"
Ejemplo n.º 2
0
                    offset_labels(Z, seg_idx, labels, this_slice_offset)
                    this_slice_offset += numregions
                    total_regions += numregions
                condensed_count = condense_labels(Z, numsegs, labels)
                print "Labeling depth %d: original %d, condensed %d" % (Z, this_slice_offset, condensed_count)
                for seg_idx in range (numsegs):
                    offset_labels(Z, seg_idx, labels, cross_Z_offset)
                cross_Z_offset += condensed_count
                # XXX - apply cross-D offset
            print "Labeling took", int(time.time() - st), "seconds, ", condense_labels.total_time, "in condensing"
            print cross_Z_offset, "total labels", total_regions, "before condensing"

            if DEBUG:
                assert np.max(labels) == cross_Z_offset

            areas, exclusions, links = overlaps.count_overlaps_exclusionsets(numslices, numsegs, labels, link_worth, maximum_link_distance)
            num_segments = len(areas)
            assert num_segments == cross_Z_offset + 1  # areas includes an area for 0

            st = time.time()
            model, links_to_segs = build_model(areas, exclusions, links)
            print "Building MILP took", int(time.time() - st), "seconds"

            # free memory
            areas = exclusions = links = None
            gc.collect()

            print "Solving"
            model.solve()
            print "Solving took", int(time.time() - st), "seconds"
Ejemplo n.º 3
0
            Z, this_slice_offset, condensed_count)
        for seg_idx in range(numsegs):
            rh.offset_labels(Z, seg_idx, labels, cross_Z_offset)
        cross_Z_offset += condensed_count
        # XXX - apply cross-D offset
    print "Labeling took", int(
        time.time() -
        st), "seconds, ", condense_labels.total_time, "in condensing"
    print cross_Z_offset, "total labels", total_regions, "before condensing"

    if debugFlag:
        assert np.max(labels) == cross_Z_offset
    print zdim
    print total_regions
    if total_regions > zdim:  #this happens when there is one label per slice (no fusion to do)
        areas, exclusions, links = overlaps.count_overlaps_exclusionsets(
            numslices, numsegs, labels, rh.link_worth)
        num_segments = len(areas)
        assert num_segments == cross_Z_offset + 1  # areas includes an area for 0

        st = time.time()
        #print 'use this number'
        #print exclusions
        model, links_to_segs = rh.build_model(areas, exclusions, links)
        print "Building MILP took", int(time.time() - st), "seconds"

        # free memory
        areas = exclusions = links = None
        gc.collect()

        print "Solving"
        model.solve()
Ejemplo n.º 4
0
    total_regions = 0
    cross_D_offset = 0
    for D in range(depth):
        this_D_offset = 0
        for Seg in range(numsegs):
            temp, numregions = ndimage_label(segmentations[Seg, D, :, :][...], output=np.int32)
            labels[Seg, D, :, :] = temp
            offset_labels(D, Seg, labels, this_D_offset)
            this_D_offset += numregions
            total_regions += numregions
        condensed_count = condense_labels(D, numsegs, labels)
        print "Labeling depth %d: original %d, condensed %d" % (D, this_D_offset, condensed_count)
        for Seg in range (numsegs):
            offset_labels(D, Seg, labels, cross_D_offset)
        cross_D_offset += condensed_count
        # XXX - apply cross-D offset
    print "Labeling took", int(time.time() - st), "seconds, ", condense_labels.total_time, "in condensing"
    print cross_D_offset, "total labels", total_regions, "before condensing"

    if DEBUG:
        assert np.max(labels) == cross_D_offset 

    areas, exclusions, overlaps = overlaps.count_overlaps_exclusionsets(depth, numsegs, labels, link_worth)
    num_segments = len(areas)
    assert num_segments == cross_D_offset + 1  # areas includes an area for 0

    st = time.time()
    build_model(open("theproblem.lp", "w"), areas, exclusions, overlaps)
    print "Building MILP too<k", int(time.time() - st), "seconds"

Ejemplo n.º 5
0
    )
    total_regions = 0
    cross_D_offset = 0
    for D in range(depth):
        this_D_offset = 0
        for Seg in range(numsegs):
            temp, numregions = ndimage_label(segmentations[Seg, D, :, :][...], output=np.int32)
            labels[Seg, D, :, :] = temp
            offset_labels(D, Seg, labels, this_D_offset)
            this_D_offset += numregions
            total_regions += numregions
        condensed_count = condense_labels(D, numsegs, labels)
        print "Labeling depth %d: original %d, condensed %d" % (D, this_D_offset, condensed_count)
        for Seg in range(numsegs):
            offset_labels(D, Seg, labels, cross_D_offset)
        cross_D_offset += condensed_count
        # XXX - apply cross-D offset
    print "Labeling took", int(time.time() - st), "seconds, ", condense_labels.total_time, "in condensing"
    print cross_D_offset, "total labels", total_regions, "before condensing"

    if DEBUG:
        assert np.max(labels) == cross_D_offset

    areas, exclusions, overlaps = overlaps.count_overlaps_exclusionsets(depth, numsegs, labels, link_worth)
    num_segments = len(areas)
    assert num_segments == cross_D_offset + 1  # areas includes an area for 0

    st = time.time()
    build_model(open("theproblem.lp", "w"), areas, exclusions, overlaps)
    print "Building MILP too<k", int(time.time() - st), "seconds"