Combine two single-channel TIFF stacks to a single

2019-05-23 05:52发布

问题:

I've got two tiff stacks with time-lapse data corresponding to different channels acquired in a microscopy experiment. I'd like to merge them into a single stack with two channels. Both stacks are 16-bit greyscale.

When I use:

convert stack1.tiff stack2.tiff stack_merged.tiff

I get a single but concatenated file with two stacks one after another.

Links to file 1 and file 2.

回答1:

I think you need something like this:

#!/bin/bash

# Get index of last frame in TIFF image
last=$(convert stack1.tif -print "%[fx:n-1]" null:)

# Combine all frames
for i in `seq 0 $last`; do
   convert stack1.tif[$i] stack2.tif[$i] -combine miff:-
done | convert miff:- -compress lzw result.tif