Created
November 5, 2015 13:37
-
-
Save freeman-lab/9897745df7b3e543bbe8 to your computer and use it in GitHub Desktop.
Hack to split images along black gaps
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
from numpy import array | |
from thunder import Images, ThunderContext | |
tsc = ThunderContext.start() | |
rawpath = '' | |
savepath = '' | |
data = tsc.loadImages(rawpath, inputFormat='tif', nplanes=1) | |
width = 512 | |
gap = 102 | |
n = 4 | |
def split(oim): | |
im = array([oim[width*i + gap*i: width*(i + 1) + gap*i, 0:width] for i in range(n)]) | |
return im.transpose(1, 2, 0) | |
corrected = Images(data.rdd.mapValues(split)) | |
corrected.saveAsBinaryImages(savepath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment