Created
September 17, 2013 00:01
-
-
Save tdsmith/6588350 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tifffile as tf | |
import numpy as np | |
from os.path import splitext | |
def z_project(fn): | |
tiff = tf.TiffFile(fn) | |
n = len(tiff.pages) | |
immap = np.arange(n).reshape((-1, 2), order='F') | |
d = {} | |
d['cars'] = immap[:-1,0] | |
d['srs'] = immap[:,1] | |
for name, inds in d.iteritems(): | |
a = np.array([tiff[ind].asarray() for ind in inds]) | |
a.sort(axis=0) # intensity projection | |
outname = '%s-%s.tif' % (splitext(fn)[0], name) | |
tf.imsave(outname, a[-1,:,:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One can simply use:
np.amax(img, axis=0)
(withimg
being the ndarray with slices first)