Skip to content

Instantly share code, notes, and snippets.

@freeman-lab
Created November 5, 2015 13:37
Show Gist options
  • Save freeman-lab/9897745df7b3e543bbe8 to your computer and use it in GitHub Desktop.
Save freeman-lab/9897745df7b3e543bbe8 to your computer and use it in GitHub Desktop.
Hack to split images along black gaps
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