Last active
January 16, 2018 12:55
-
-
Save ericspod/e5dd6bde055f0bf589a82230d687e00e to your computer and use it in GitHub Desktop.
Cropping an Image in Z and T dimensions
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
# Copy this function into the Eidolon console then you can call it as described below. | |
def cropImage(img,minz,maxz,mint,maxt): | |
'''Crop image `img' in the Z (minz to maxz) and T dimensions (mint to maxt).''' | |
arr=img.plugin.getImageObjectArray(img) # break the image down into spatial components and numpy array | |
arr['array']=arr['array'][:,:,minz:maxz,mint:maxt] # crop the numpy array | |
arr['pos']=img.images[img.getVolumeStacks()[0][minz]].position # set the position to the bottom of the new stack | |
newimg=img.plugin.createObjectFromArray(img.getName()+'Crop',**arr) # create new image object | |
mgr.addSceneObject(newimg) # add image to scene | |
return newimg # return image | |
# Use like this to crop first loaded image (which is stored in mgr.objs[0]): | |
newimg=cropImage(mgr.objs[0],2,5,0,10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment