bigregister
index
/.automount/ioasun3/root/disk/users/kybic/work/python_volumes/bigregister.py

 Module bigregister contains functions for performing
registration between two images representing the deformation using
B-splines
 
Jan Kybic, August-November 2000
$Id: bigregister.html,v 1.1 2002/08/26 14:11:15 jkybic Exp $

 
Modules
                      
BIGsplines
Gnuplot
Image
ImageFilter
bigmultigrid
bigoptimize
bigpyramid
bigsplines
bigtools
copy
copy_reg
math
multiarray
pickle
string
time
types

 
Classes
                      
bigoptimize.EvaluableProblem
SpringRegularizedWarpingProblem
WarpingProblem(bigoptimize.EvaluableProblem, ZeroRegularizer)
bigoptimize.SplineReducer(bigoptimize.SimpleReducer)
MultigridableWarpingProblem
SpringProblem
WarpableImage
WarpingRegularizer
ZeroRegularizer
WarpingProblem(bigoptimize.EvaluableProblem, ZeroRegularizer)

 
class MultigridableWarpingProblem(bigoptimize.SplineReducer)
            Generate a multigriddable variant of the WarpingProblem.
An instance is generated given a reference and test pyramids,
a class of the WarpingProblem, the size of the control grid,
and degrees of splines to interpolate the deformation and
the image.
 
  
__init__(self, refp, testp, xshape=None, degf=3, degc=3, wp=<class bigregister.WarpingProblem>, level=0, reducedimg=0, alpha=0.0, verbose=0, mask=None)
canReduce(self)
canReduceC(self)
canReduceImg(self)
denormalizeC(self, c)
expand(self, x, targetlen=None) from bigoptimize.SplineReducer
expandexceptfirst(self, x, targetlen=None) from bigoptimize.SimpleReducer
getE(self, c, visualize=0, gnupl=None)
getEg(self, c)
getEgDh(self, c)
getEgH(self, c)
getInitialX(self)
getReduced(self, c)
 gets a reduced version of the problem. Here, the strategy is
to alternatively reduce the size of the images and of the control
points
getReducedMask(self, mask)
 Given a bitmap mask, reduce it to half the size
getsplinedegree(self) from bigoptimize.SplineReducer
reduce(self, x) from bigoptimize.SplineReducer
reduceX(self, x)
reduceexceptfirst(self, x) from bigoptimize.SimpleReducer
simpleexpand(self, x, targetlen=None) from bigoptimize.SimpleReducer
simplereduce(self, x) from bigoptimize.SimpleReducer
updateFine(self, xf, xc0, xc1)

 
class SpringProblem
            This serves as a regularizer for the WarpingProblem.
It evaluates
 
Es=sum_q omega_q | g(x_i)/N-z_i |^2
 
(where N is the number of pixels in the specific direction)
and its derivatives with respect to c(describing g).
x and z should have values between 0..1, x will be later
multiplied by the image size in the given direction and
converted to integer pixel coordinates to improve performance.
 
For the moment it only works in 2D.
 
  
__init__(self, wp, x, z, omega)
 Takes as parameters: the asociated WarpingProblem(wp),
and the parameters (x,z,omega) of the springs
getE(self, cc)
getEg(self, cc)

 
class SpringRegularizedWarpingProblem(bigoptimize.EvaluableProblem)
            Combines WarpingProblem and SpringProblem
 
  
__init__(self, refimg, testimgc, csize=None, degf=3, degc=3, alpha=0.0, verbose=0, mask=None, springx=array([ [ 0., 0.]]), springz=array([ [ 0., 0.]]), springomega=array([ 0.]))
dHerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
denormalizeC(self, c)
gerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
getE(self, cc, visualize=0, gnupl=None)
getEg(self, cc)
getEgDh(self, x) from bigoptimize.EvaluableProblem
getInitialX(self)
normalizeC(self, c)
numDh(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
numg(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem

 
class WarpableImage
            contains an n-dimensional image which can be warped
if mask is defined, only pixels set in the mask will be considered
 
  
__init__(self, image, degf=3, degc=2, imageiscoefs=0, verbose=0, mask=None)
getC(self)
 returns a reference to the c coefficient matrix describing
the deformation. The matrix should not be modified
getDeformation(self)
getDeformationDerivative(self, flag=0)
getDisplacementAtPoint(self, point, flag=0)
 Gets displacement at 'point'
getDisplacementAtPoints(self, points, flag=0)
 Gets displacement at multiple 'points' of size (n,dim),
(which is the transpose of what interpoldef wants)
It returns the diplacements in the same format (n,dim)
getWarped(self)
interpoldef(self, i, m, flag=0)
setC(self, c)
 remembers the reference to a matrix c, which should not be
modified while needed.
setDeformation(self, tbl)
setIdentity(self, shape)
 initializes deformation as identity with a given shape
the shape should be (n,x1,x2,..,xn)

 
class WarpingProblem(bigoptimize.EvaluableProblem, ZeroRegularizer)
            Accepts two images, reference and test, the test image in the
form of  its B-spline coefficients, as well as the suggested size
of the coefficients c describing the deformation and the degree
of B-splines to represent the deformation. Evaluates the SSD
criterion and its first and second derivatives.
 
Alpha is the factor in the regularization part E=Ed+alpha Er
where Er is whatever is returned by WarpingRegularizer
 
The coefficients c are normalized, i.e. multiplied by the size of the
image in the specific direction. This way, even if the image size
changes, the appropriate c coefficients will not.
 
If mask is defined, only pixels in the mask will be taken into account
 
implements the interface of EvaluableProblem
 
  
__init__(self, refimg, testimgc, csize=None, degf=3, degc=3, alpha=0.0, verbose=0, mask=None)
dHerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
denormalizeC(self, c)
 Multiply components of c responsible for movements with respect
to each axis by the number of pixels in this axis. Also usable for
gradient and Hessian diagonal normalization
gerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
getDerivatives(self)
 get first derivatives of the image described by coefs
self.w.b along the coordinate axis
getE(self, cc, visualize=0, gnupl=None)
getEg(self, cc)
getEgC(self, cc)
 The fast version of getEgPython, using a C implementation.
Limitation: only works in 2D
getEgDh(self, cc)
getEgDhr(self, c) from ZeroRegularizer
getEgH(self, cc)
 evaluate the criterion, gradient, and the true Hessian
slow implementation for the moment. Does not support
regularization.
getEgPython(self, cc)
getEgr(self, c) from ZeroRegularizer
getEr(self, c) from ZeroRegularizer
getInitialX(self)
getSecondDerivatives(self)
 get second derivatives of the image described by coefs
self.w.b along the coordinate axis
initRegularizer(self) from ZeroRegularizer
normalizeC(self, c)
 Inverse of denormalizeC
numDh(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
numg(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem

 
class WarpingRegularizer
            A helper class for WarpingProblem. Evaluates the regularization
part of the criterion.
 
  
getEgDhr(self, c)
getEgr(self, c)
getEr(self, c)
initRegularizer(self)

 
class ZeroRegularizer
            A helper class for WarpingProblem. Evaluates the regularization
part of the criterion as zero.
 
  
getEgDhr(self, c)
getEgr(self, c)
getEr(self, c)
initRegularizer(self)

 
Functions
                      
alltrue = reduce(...)
array(...)
array(sequence, typecode=None, copy=1, savespace=0) will return a new array formed from the given (potentially nested) sequence with type given by typecode.  If no typecode is given, then the type will be determined as the minimum type required to hold the objects in sequence.  If copy is zero and sequence is already an array, a reference will be returned.  If savespace is nonzero, the new array will maintain its precision in operations.
calculateMask(img, pct, degf=3)
 Calculates mask for img, such that it contains 'pct'
pixels with the highest gradient values
calculateThresholdedMask(img, threshold=30, degs=5)
 Calculates mask for img, such that it contains pixels
with values higher than threshold.
degs is roughly the half size of the holes to be filled in,
similar to morphological closing. When degs=0, no filling
is performed.
choose(...)
choose(a, (b1,b2,...))
cross_correlate(...)
cross_correlate(a,v)
cumproduct = accumulate(...)
cumsum = accumulate(...)
fromstring(...)
fromstring(string, count=None, typecode='l') returns a new 1d array initialized from the raw binary data in string.  If count is not equal to None, the new array will have count elements, otherwise it's size is determined by the size of string.
product = reduce(...)
repeat(...)
repeat(a, n, axis=0)
reshape(...)
reshape(a, (d1, d2, ..., dn)).  Change the shape of a to be an n-dimensional array with dimensions given by d1...dn.  One dimension is allowed to be None.  This dimension will be set to whatever value will make the size of the new array equal the size of the old one.  Note: the size specified for the new array must be exactly equal to the size of the  old one or an error will occur.  This returns a completely new array with the data of the old one copied.  Use a.shape=(...) for no data copying.
searchsorted = binarysearch(...)
binarysearch(a,v)
sometrue = reduce(...)
sum = reduce(...)
take(...)
take(a, indices, axis=0).  Selects the elements in indices from array a along the given axis.
test_1dWP()
test_2dWP()
test_3dWP()
test_WarpableImage()
test_WarpingProblem()
test_lena()
test_mask()
time_getEg()
zeros(...)
zeros((d1,...,dn),typecode,savespace) will return a new array of shape (d1,...,dn) and type typecode (default 'l') with all it's entries initialized to zero.  If savespace (default 0) is nonzero the array will be a spacesaver array.

 
Constants
                      ArrayType = <type 'array'>
Complex = 'D'
Complex0 = 'F'
Complex16 = 'F'
Complex32 = 'F'
Complex64 = 'D'
Complex8 = 'F'
Float = 'd'
Float0 = 'f'
Float16 = 'f'
Float32 = 'f'
Float64 = 'd'
Float8 = 'f'
Int = 'l'
Int0 = '1'
Int16 = 's'
Int32 = 'i'
Int8 = '1'
LittleEndian = 1
PrecisionError = 'PrecisionError'
PyObject = 'O'
UnsignedInt8 = 'b'
arraytype = <type 'array'>
e = 2.7182818284590451
pi = 3.1415926535897931