| |
- bigoptimize.EvaluableProblem
-
- DProjProblem
- MultigridableWarpingProblemBase
-
- MultigridableWarpingProblemSQ
- MultigridableWarpingProblemSprings
- MultigridableWarpingProblemWI
- WarpingProblemS
-
- MultigridableWarpingProblemSDataPart
- MWPSequencePlugin
- MWPSpringPlugin
- MWPWarpIndexPlugin
- WarpableImageS
class DProjProblem(bigoptimize.EvaluableProblem) |
|
Implements a task of evaluating the distance between two
deformations, one given by a WarpableImageS object and second
by a table of values. Suitable for minimization using optimizerGdesQ
and similar.
Implements the interface of EvaluableProblem. |
| - __init__(self, wi, tbl, mask=None)
- wi is a WarpableImageS, tbl a table as returned from
WarpableImageS.getDeformation
- dHerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- gerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- getE(self, c)
- Calculate the criterion for a particular c
- getEg(self, c)
- getEgDh(self, x) from bigoptimize.EvaluableProblem
- getInitialX(self)
- Return the initial state of the deformation.
It is a private copy of the array, it will not change with time
- getX(self)
- Currently homonyme for getInitialX(). Returns the last value
used for the calculation
- numDh(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- numg(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- setX(self, x)
- Sets the deformation parameters to x. This functions is
automatically called whenever new calculation of E or g is needed.
|
class MWPSequencePlugin |
|
This is an auxiliary plug-in class to be used in derivatives of
MultigridableWarpingProblemBase.
It returns a sequence of images illustrating the optimization.
It accepts parameters:
fileseqmask - the full filename including a printf-style placeholder
for image number, for example 'regseq%04d.tiff'
imgsize - target size of a single image, we currently make
a sequence of images about 2*imgsize+10 |
| - __init__(self, par=None, datapart=None)
- canReduce(self)
- getE(self, x)
- getEg(self, x)
- getReduced(self, datapart=None)
- Returns a reduced version of the plugin.
- makeimg(self, x)
- Creates an image corresponding to current state.
For second and subsequent evaluation, if the criterion increases,
previous images are being used (to reconsider)
|
class MWPSpringPlugin |
|
This is a auxiliary plug-in class to be used in derivatives of
MultigridableWarpingProblemBase. It represents the landmark
spring constraints.
New parameters in par are springfactor, springpos, springtarget
The added part of the criterion is:
Espring=Sum springfactor(i)*||g(springpos(i))-springtarget(i)||^2
springpos,springtarget and springfactor should be arrays with first
dimension equal to N, the number of springs. |
| - __init__(self, par=None, datapart=None)
- canReduce(self)
- getE(self, x)
- Calculate the contribution of the springs. Note that it is
crucial that the DataPart is evaluated before the spring part,
so that the deformation is already set. That's why x is not
used in this function
- getEg(self, x)
- See comment at getE
- getReduced(self, datapart=None)
- Returns a reduced version of the spring plug-in.
|
class MWPWarpIndexPlugin |
|
This is an auxiliary plug-in class to be used in derivatives of
MultigridableWarpingProblemBase. It returns the trajectory of the
optimization process: the values of the energy and the warping index.
It accepts parameters:
trueg - (the true deformation as returned by getDefS),
reslist - a list of tuples (imgsize,crate,E,wi)
wimask - the mask as returned for example by
bigregister.calculateThresholdedMask
When on the parameter 'measuretime' is set, none of the above is
calculated and the reslist contains the list of times as returned by
time.clock() |
| - __init__(self, par=None, datapart=None)
- canReduce(self)
- evalwi(self, x)
- Evaluates the state of the optimization and appends it to
the self.par.reslist list
For second and subsequent evaluation, if the criterion increases,
values from previous (successful) evaluation are used instead.
- getE(self, x)
- getEg(self, x)
- getReduced(self, datapart=None)
- Returns a reduced version of the warpindex plugin.
- reduceMask(self, m)
- Take a binary mask m and reduce it by half
|
class MultigridableWarpingProblemBase(bigoptimize.EvaluableProblem) |
|
This is the basis versions of a WarpingProblemS.
Additional plug-in criteria parts can be added.
The object of a created class supports the following
interface methods:
__init__(self,par=None)
getInitialX,getE,getEg,setX
canReduce,getReduced,getXstate,getXcopy,updateFine
These interface methods must be supported by the first (DataPart)
client object, the auxiliary ones only need to support
getE,getEg,canReduce,getReduced
The auxiliary criterion objects will get an additional keyword argument
datapart for their __init__ and getReduced() methods and
should access the current state
through this pointer.
The possible parameters object par attributes are refimg,
testimg, testw, and many others |
| - __init__(self, par=None)
- canReduce(self)
- Relay the call to all members and accumulate
- dHerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- gerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- getE(self, x)
- Relay the call to all members and accumulate
- getEg(self, x)
- Relay the call to all members and accumulate
- getEgDh(self, x) from bigoptimize.EvaluableProblem
- getInitialX(self)
- Gets the initial value of X. We only relay this call
to the first (data part) member
- getReduced(self)
- Returns an object of my own class, containing reduced
versions of myself and the auxiliary criterion parts.
- getX(self)
- Gets the value of X. We only relay this call
to the first (data part) member
- getXcopy(self)
- Relay the call to the data part
- getXstate(self)
- Relay the call to the data part
- numDh(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- numg(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- setX(self, x)
- Relay the call to the data part
- setXstate(self, x)
- Relay the call to the data part
- updateFine(self, xc0, cp)
- Relay the call to the data part
|
class MultigridableWarpingProblemSDataPart(WarpingProblemS) |
|
Implements the multigridable version of WarpingProblemS.
The added methods are canReduce(), getReduced(), updateFine()
When reducing, we will alternatively coarsen the image and
the deformation grid, or coarsen both at the same time (default).
Remark: For the moment, we consider only uniform coarsening
of the deformation grid
If grmask is nonzero, gradient mask is automatically computed at
each level with this percentage of active pixels.
It is not intended to be run independently. Instead it will be
a part of a WarpingProblemS object, together with other parts
of the criteria. |
| - __init__(self, par=None)
- The par members refimg and testimg
are either an array or a MSplineSignal.
Alternatively, you can specify testw
(a WarpableImageS) directly
- canReduce(self)
- True if any coarsening is possible
- canReduceDef(self)
- Returns true if the deformation can be further coarsened
- canReduceImg(self)
- True if Img can be reduced
- dHerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- gerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- getE(self, c) from WarpingProblemS
- getEg(self, c) from WarpingProblemS
- getEgDh(self, x) from bigoptimize.EvaluableProblem
- getGradientMask(self, pct=10)
- Calculates a mask of refimg, such that it contains 'pct'
pixels with the highest gradient values
NOTE: This is not very efficient, as we generate the WarpableImageS
first
- getInitialX(self) from WarpingProblemS
- getReduced(self)
- Returns a reduced version of the MultigridableWarpingProblemS
the particular reducing method can be chosen by the parameters
- getReducedAlternate(self)
- Returns a reduced version of the MultigridableWarpingProblemS,
alternatively reducing the image size and the deformation
grid size.
- getReducedDef(self)
- Returns a reduced version of the MultigridableWarpingProblemS
with reduced deformation grid.
- getReducedImg(self)
- Returns a reduced version of the MultigridableWarpingProblemS
with reduced images and possibly also the deformation grid,
if needed
- getReducedImgAndDef(self)
- Reduce both image and deformation grid
- getX(self) from WarpingProblemS
- getXcopy(self)
- Get a copy of the current state, to be used with updateFine()
- getXstate(self)
- Get the current state (no copy), to be used with updateFine()
- numDh(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- numg(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- setX(self, x) from WarpingProblemS
- setXstate(self, x)
- Converse of getXstate() or getXcopy()
- updateFine(self, xc0, cp)
- Update yourself from the result of coarse level computation.
xc0 is the coarse grid value received from cp.getXcopy()
(a private copy) before the coarse grid representation.
It might or might not be an array.
cp is the coarse level MultigridableWarpingProblemS in its
final state. The new fine value is
xforig+Expand(xc1-xc0)
|
class MultigridableWarpingProblemSQ(MultigridableWarpingProblemBase) |
|
WarpingProblem including the sequence plugin |
| - __init__(self, par=None) from MultigridableWarpingProblemBase
- canReduce(self) from MultigridableWarpingProblemBase
- dHerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- gerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- getE(self, x) from MultigridableWarpingProblemBase
- getEg(self, x) from MultigridableWarpingProblemBase
- getEgDh(self, x) from bigoptimize.EvaluableProblem
- getInitialX(self) from MultigridableWarpingProblemBase
- getReduced(self) from MultigridableWarpingProblemBase
- getX(self) from MultigridableWarpingProblemBase
- getXcopy(self) from MultigridableWarpingProblemBase
- getXstate(self) from MultigridableWarpingProblemBase
- numDh(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- numg(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- setX(self, x) from MultigridableWarpingProblemBase
- setXstate(self, x) from MultigridableWarpingProblemBase
- updateFine(self, xc0, cp) from MultigridableWarpingProblemBase
|
class MultigridableWarpingProblemSprings(MultigridableWarpingProblemBase) |
|
WarpingProblem including the spring regulatization |
| - __init__(self, par=None) from MultigridableWarpingProblemBase
- canReduce(self) from MultigridableWarpingProblemBase
- dHerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- gerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- getE(self, x) from MultigridableWarpingProblemBase
- getEg(self, x) from MultigridableWarpingProblemBase
- getEgDh(self, x) from bigoptimize.EvaluableProblem
- getInitialX(self) from MultigridableWarpingProblemBase
- getReduced(self) from MultigridableWarpingProblemBase
- getX(self) from MultigridableWarpingProblemBase
- getXcopy(self) from MultigridableWarpingProblemBase
- getXstate(self) from MultigridableWarpingProblemBase
- numDh(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- numg(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- setX(self, x) from MultigridableWarpingProblemBase
- setXstate(self, x) from MultigridableWarpingProblemBase
- updateFine(self, xc0, cp) from MultigridableWarpingProblemBase
|
class MultigridableWarpingProblemWI(MultigridableWarpingProblemBase) |
|
WarpingProblem including the warping index calculation |
| - __init__(self, par=None) from MultigridableWarpingProblemBase
- canReduce(self) from MultigridableWarpingProblemBase
- dHerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- gerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- getE(self, x) from MultigridableWarpingProblemBase
- getEg(self, x) from MultigridableWarpingProblemBase
- getEgDh(self, x) from bigoptimize.EvaluableProblem
- getInitialX(self) from MultigridableWarpingProblemBase
- getReduced(self) from MultigridableWarpingProblemBase
- getX(self) from MultigridableWarpingProblemBase
- getXcopy(self) from MultigridableWarpingProblemBase
- getXstate(self) from MultigridableWarpingProblemBase
- numDh(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- numg(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- setX(self, x) from MultigridableWarpingProblemBase
- setXstate(self, x) from MultigridableWarpingProblemBase
- updateFine(self, xc0, cp) from MultigridableWarpingProblemBase
|
class WarpableImageS |
|
contains n-dimensional image to be warped.
Reimplementation of bigregister.WarpableImage using MSplineSignal
The ratio between the image size and the control grid size
is now constrained to be an integer 'crate' (actually a vector)
The deformation is a list of MSplineSignals, 'defs', one element for
each component . It coincides with 'imgs' at zero and goes 'crate'
times slower. |
| - __init__(self, imgs, defs=None, par=None, c=None, mask=None)
- imgs is supposed to be MSplineSignal or an array,
defs is either None, or a MSplineSignalList
If imgs is an array, we convert it.
The deformation defaults to identity, or it can be given
by the MSplineSignal defs or the matrix c
If mask is not None it determines which pixel values are
going to be evaluated. It should have the same size as
the image imgs. For the moment, only the calculation
of the warped image is affected.
- cRateIsEven(self)
- True if all elements of crate are even
- getCAsArray(self)
- Unpacks the coefficients of the deformation to an array
- getContrib(self, x)
- Returns an array of the size of self.defs.l[0].c which contains
the spline values of the corresponding spline functions at point x
- getDefS(self)
- Return pointer the defs MSplineSignalList
- getDeformation(self)
- Get the deformation function at all points, caching the
results.
NOTE: mask could have been used here, but it is not,
as evalfract does not support it anyway.
- getDeformationAtPoints(self, pts)
- Gets target position of multiple points pts of size (n,dim),
(which is the transpose of what interpoldef wants)
It returns the diplacements in the same format (n,dim)
- getDerivatives(self)
- get all first derivatives of the image
- getExpandedDef(self)
- Returns an equivalent version of WarpableImageS with twice
expanded deformation grid. crate is divided by two
- getImageS(self)
- Return pointer to imgs
- getReducedDef(self)
- Returns an equivalent version of WarpableImageS with twice
reduced deformation grid. crate is multiplied by two
- getReducedImg(self)
- Returns an equivalent version of WarpableImageS with twice
reduced image and correspondingly modified deformation structure
- getReducedImgAndDef(self)
- Returns an equivalent version of WarpableImageS with twice
reduced image and twice reduced deformation grid.
crate stays constant
- getWarped(self, g=None)
- Get the warped image as an array
- getWarpedOther(self, img)
- Warp an image img
with the same deformation as myself, expanding appropriately
- getWarpingIndex(self, c, mask=None)
- Calculates the warping index (average geometric error) between
the current deformation and the deformation given by c.
The mask here is positive, i.e. 1 means consider, 0 do not consider
- getWarpingIndexDefS(self, defs, par, mask=None)
- Calculates the warping index (average geometric error) between
the current deformation and deformation given by defs and
par (from which crate, degc are taken)
- getWarpingIndexG(self, g0, mask=None)
- Calculates the warping index (average geometric error) between
the current deformation and deformation given by g
and mask
- setCFromArray(self, c)
- Sets the internal representation of a deformation from an
array c
- setDefS(self, defs)
- Set a new defs, invalidating the deformation
- setIdentity(self)
- setMask(self, mask)
- setProjection(self, g0, mask=None)
- Given a conforming deformation table g0, set coefficients
of the deformation so that it is as close as possible (in the
warping index sense) to g0
|
class WarpingProblemS(bigoptimize.EvaluableProblem) |
|
Implements the accelerated variant of the single-scale
warping problem. Mostly compatible with bigregister.WarpingProblem
Accepts two images: reference and test. Reference is an array,
test is a MSplineSignal which will be embedded in
ReducWarpableImageS.
The criterion is SSD per pixel.
Implements the interface of EvaluableProblem. |
| - __init__(self, refimg, testimg=None, testw=None, par=None, mask=None)
- refimg is an array, testimg a MSplineSignal
or an array. Alternatively, you can specify testw
(a WarpableImageS) directly
- dHerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- gerr(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- getE(self, c)
- Calculate the criterion for a particular c
- getEg(self, c)
- Calculate the criterion and its gradient for some c
- getEgDh(self, x) from bigoptimize.EvaluableProblem
- getInitialX(self)
- Return the initial state of the deformation.
It is a private copy of the array, it will not change with time
- getX(self)
- Currently homonyme for getInitialX(). Returns the last value
used for the calculation
- numDh(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- numg(self, x, h=9.9999999999999995e-07) from bigoptimize.EvaluableProblem
- setX(self, x)
- Sets the deformation parameters to x. This functions is
automatically called whenever new calculation of E or g is needed.
| |