Пример #1
0
def caller(inputs, inputs_labels, output, functions, params):
    make_dirs(output)

    # Make cells. cells are a list of regionproperties or subclasses.
    logger.info('Postprocess.\tcollecting cells...')
    store = []
    for frame, (path, pathl) in enumerate(zip(inputs, inputs_labels)):
        img, labels = imread(path), lbread(pathl)
        cells = regionprops(labels, img)
        cells = [Cell(cell) for cell in cells]
        for cell in cells:
            cell.frame = frame
            if frame > 0:
                all_labels = [i.label for i in store[frame - 1]]
                if cell.label in all_labels:
                    store[frame - 1][all_labels.index(cell.label)].nxt = cell
        store.append(cells)
    cells = [i for j in store for i in j]

    # Each function receives cells (regionprops) and finally return labels generated by cells.label
    for function, param in zip(functions, params):
        logger.info('\trunning {0}'.format(function))
        func = getattr(postprocess_operation, function)
        cells = func(cells, **param)

    logger.info('\tsaving images...')
    for frame, (path, pathl) in enumerate(zip(inputs, inputs_labels)):
        labels = cells2labels(cells, frame, lbread(pathl))
        imsave(labels, output, path, dtype=np.int16)
Пример #2
0
def caller(inputs, inputs_labels, output, functions, params):
    make_dirs(output)
    inputs = inputs[FRAME_REVTRACK:0:-1] + inputs
    inputs_labels = inputs_labels[FRAME_REVTRACK:0:-1] + inputs_labels

    img0, labels0 = imread(inputs[0]), lbread(inputs_labels[0]).astype(
        np.int16)
    labels0 = neg2poslabels(labels0)
    imsave(labels0, output, basename(inputs[0]), dtype=np.int16)
    for holder.frame, (path,
                       pathl) in enumerate(zip(inputs[1:], inputs_labels[1:])):
        img1, labels1 = imread(path), lbread(pathl)
        labels1 = -labels1
        for fnum, (function, param) in enumerate(zip(functions, params)):
            func = getattr(track_operation, function)
            if not (labels1 < 0).any():
                continue
            labels0, labels1 = func(img0, img1, labels0, -labels1, **param)
            logger.debug('\t{0} with {1}: {2}'.format(
                function, param, len(set(labels1[labels1 < 0]))))
        logger.info("\tframe {0}: {1} objects linked and {2} unlinked.".format(
            holder.frame, len(set(labels1[labels1 > 0])),
            len(set(labels1[labels1 < 0]))))
        labels0 = neg2poslabels(labels1)
        img0 = img1
        imsave(labels0, output, path, dtype=np.int16)
Пример #3
0
def caller(inputs, output, functions, params):
    holder.inputs = inputs
    make_dirs(output)

    logger.info("Functions {0} for {1} images.".format(functions, len(inputs)))

    for holder.frame, holder.path in enumerate(inputs):
        img = imread(holder.path)
        for function, param in zip(functions, params):
            func = getattr(preprocess_operation, function)
            img = func(img, **param)
        imsave(img, output, holder.path)
        logger.info("\tframe {0} done.".format(holder.frame))
Пример #4
0
def caller(inputs, output, functions, params):
    make_dirs(output)
    logger.info("Functions {0} for {1} images.".format(functions, len(inputs)))

    for holder.frame, path in enumerate(inputs):
        img = imread(path)
        for function, param in zip(functions, params):
            func = getattr(segment_operation, function)
            img = func(img, **param)
        if isinstance(path, list) or isinstance(path, tuple):
            path = path[0]
        labels = clean_labels(img, radius)
        imsave(labels, output, path, dtype=np.int16)
        logger.info("\tframe {0}: {1} objects segmented.".format(
            holder.frame, len(np.unique(labels))))
Пример #5
0
def caller(inputs, inputs_labels, output, functions, params):
    make_dirs(output)

    logger.info("Functions {0} for {1} images.".format(functions, len(inputs)))
    img = None
    for holder.frame, (path,
                       pathl) in enumerate(izip_longest(inputs,
                                                        inputs_labels)):
        if path is not None:
            img = imread(path)
        labels0 = lbread(pathl)
        for function, param in zip(functions, params):
            func = getattr(subdetect_operation, function)
            if img is not None:
                labels = func(labels0, img, **param)
            else:
                labels = func(labels0, **param)
        imsave(labels, output, pathl, dtype=np.int16)
        logger.info("\tframe {0} done.".format(holder.frame))