Beispiel #1
0
def _horcombine(imp_collection):
    """Combine a list of stacks with the same dimensions horizontally.

    Args:
        imp_collection: A list of stacks.

    Returns:
        A horizontally combined stack of the input images.
    """
    comb = imp_collection[0]
    comb_channels = ChannelSplitter().split(comb)
    comb_channels = [i.getImageStack() for i in comb_channels]

    for imp in imp_collection:

        if imp == imp_collection[0]:
            continue

        imp_channels = ChannelSplitter().split(imp)
        imp_channels = [i.getImageStack() for i in imp_channels]
        comb_channels = [
            StackCombiner().combineHorizontally(i, j)
            for i, j in zip(comb_channels, imp_channels)
        ]

    comb_channels = [
        ImagePlus("C{}".format(i + 1), channel)
        for i, channel in enumerate(comb_channels)
    ]
    impout = RGBStackMerge().mergeChannels(comb_channels,
                                           False)  # boolean keep
    return impout
Beispiel #2
0
def CombineStacks(imp1, imp2):
    imp1stack = imp1.getStack()
    imp2stack = imp2.getStack()
    imp3stack = StackCombiner().combineVertically(imp1stack, imp2stack)
    imp3 = ImagePlus("Combined Stacks", imp3stack)
#    imp3.show()
    print imp3
    return imp3
def combine_images(imps, direction = "horizontally"):
    stack_combiner = StackCombiner()
    img_stack1 = imps[0].getImageStack()
    img_stack2 = imps[1].getImageStack()
    
    if direction == "horizontally":
        combined_stack = stack_combiner.combineHorizontally(img_stack1, img_stack2)
        for imp in imps[2:]:
            img_stack = imp.getImageStack()
            combined_stack = stack_combiner.combineHorizontally(combined_stack, img_stack)
    
    if direction == "vertically":
        combined_stack = stack_combiner.combineVertically(img_stack1, img_stack2)
        for imp in imps[2:]:
            img_stack = imp.getImageStack()
            combined_stack = stack_combiner.combineVertically(combined_stack, img_stack)
    
    combined_imp = ImagePlus("combined_image", combined_stack)
    return combined_imp