mattek
mattek

Reputation: 942

Combine two single-channel TIFF stacks to a single multi-channel stack

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.

Upvotes: 3

Views: 1413

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 208052

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

Upvotes: 2

Related Questions