Skip to content

Instantly share code, notes, and snippets.

View ericspod's full-sized avatar

Eric Kerfoot ericspod

View GitHub Profile
@ericspod
ericspod / pcrtest.py
Created May 16, 2018 19:22
Piecewise CR Test
from eidolon import *
# The Catmull-Rom basis types assume a fixed set of control points: 4 for 1D, 4**2 for 2D, and 4**3 for 3D.
# The piecewise Catmull-Rom allows a definition with an arbitrarily sized lattice of control points which is
# then divided up into individual elements which share control points of neighbours. The line example in the
# wiki shows an element composed of 3 lines. To allow the configuration of the element type, the basis function
# which returns coefficients for piecewise Catmull-Rom accepts extra parameters in addition to the xi coordinates
# (u,v,w): `ul', `vl', `wl' stating the dimensions of the control point lattice, `limits' stating for each dimension if
@ericspod
ericspod / cropZT.py
Last active January 16, 2018 12:55
Cropping an Image in Z and T dimensions
# 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