Example #1
0
from register.metrics import metric
from register.samplers import sampler
from register import register

from register.visualize import plot

# Form some test data (lena, lena rotated 20 degrees)
image = misc.lena()
template = nd.rotate(image, 20, reshape=False)

# Form the affine registration instance.
affine = register.Register(
    model.Affine,
    metric.Residual,
    sampler.CubicConvolution
    )

# Coerce the image data into RegisterData.
image = register.RegisterData(image).downsample(2)
template = register.RegisterData(template).downsample(2)

# Register.
step, search = affine.register(
    image,
    template,
    verbose=True,
    )

# Call the debug tool "searchInspector"
plot.searchInspector(search)
Example #2
0
    metric.Residual,
    sampler.CubicConvolution
    )

fullSearch = []

# Image pyramid registration can be executed like so:
pHat = None
for factor in [30., 20. , 10., 5., 2., 1.]:
    
    if pHat is not None:
        scale = downImage.coords.spacing / factor
        # FIXME: Find a nicer way to do this.
        pHat = model.Affine.scale(pHat, scale)
        
    downImage = image.downsample(factor) 
    downTemplate = template.downsample(factor) 
    
    step, search = affine.register(
        downImage,
        downTemplate,
        p=pHat,
        verbose=True
        )
    
    pHat = step.p
    
    fullSearch.extend(search)
    
plot.searchInspector(fullSearch)