示例#1
0
image = misc.lena()
template = warp(image)

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

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

# Form the spline registration instance.
spline = register.Register(model.CubicSpline, metric.Residual, sampler.Spline)

# Compute an affine registration between the template and image.
step, search = affine.register(
    image,
    template,
)

# Compute a nonlinear (spline) registration, initialized with the warp field
# found using the affine registration.
step, _search = spline.register(image,
                                template,
                                displacement=step.displacement,
                                verbose=True)

search.extend(_search)

plot.searchInspector(search)
示例#2
0
    return spline_sampler.f(image, spline_model.warp(p)).reshape(image.shape)


# Form some test data (lena, lena rotated 20 degrees)
image = register.RegisterData(misc.lena())
template = register.RegisterData(warp(misc.lena()))

# Form the registrator.
spline = register.Register(model.CubicSpline, metric.Residual, sampler.Spline)

# Image pyramid registration can be executed like so:
fullSearch = []
displacement = None

for factor in [20., 10., 5.]:

    downImage = image.downsample(factor)
    downTemplate = template.downsample(factor)

    step, search = spline.register(downImage,
                                   downTemplate,
                                   displacement=displacement,
                                   verbose=True)

    displacement = step.displacement

    fullSearch.extend(search)

plot.searchInspector(fullSearch)
示例#3
0
from imreg.visualize import plot
from imreg import register

# Form some test data (lena, lena rotated 20 degrees)
image = imread('data/frown.png')[:, :, 0]
template = imread('data/smile.png')[:, :, 0]

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

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

# Smooth the template and image.
image.smooth(1.5)
template.smooth(1.5)

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

plot.searchInspector(search)
示例#4
0
template = register.RegisterData(warp(misc.lena()))

# Form the registrator.
spline = register.Register(
    model.CubicSpline,
    metric.Residual,
    sampler.Spline
    )

# Image pyramid registration can be executed like so:
fullSearch = []
displacement = None

for factor in [ 20., 10.,  5.]:
    
    downImage = image.downsample(factor) 
    downTemplate = template.downsample(factor) 
    
    step, search = spline.register(
        downImage,
        downTemplate,
        displacement=displacement,
        verbose=True
        )
    
    displacement = step.displacement
    
    fullSearch.extend(search)
    
plot.searchInspector(fullSearch)