Exemple #1
0
    def test_with_transform(self):
        x1 = np.arange(9).reshape((3,3)) + 1
        x1[:] = 10
        x2 = x1.copy()
        theta = -np.pi/2
        M = np.array([[np.cos(theta), -np.sin(theta),  0],
                      [np.sin(theta),  np.cos(theta), +2],
                      [0,              0,              1]])

        stacked = stack.with_transform([x1, x2], [np.eye(3), M],
                                       weights=[1, 1], order=1)
        assert(np.allclose(stacked, 10))
Exemple #2
0
def initial_guess_avg(images, tf_matrices, scale, oshape):
    """From the given low-resolution images and transforms, make an
    initial guess of the high-resolution image.

    Parameters
    ----------
    images : list of ndarray
        Low-resolution images.
    tf_matrices : list of (3, 3) ndarray
        Transformation matrices that warp the images to the reference
        image (usually ``images[0]``).
    scale : float
        The scale of the high-resolution reconstruction relative to the
        low-resolution frames.  Typically between 1 and 2.
    oshape : tuple of int
        Shape of the high-resolution reconstruction.

    """
    HH = [x.copy() for x in tf_matrices]
    for H in HH:
        H[:2, :] *= float(scale)

    return stack.with_transform(images, HH, oshape=oshape, order=3)
Exemple #3
0
def initial_guess_avg(images, tf_matrices, scale, oshape):
    """From the given low-resolution images and transforms, make an
    initial guess of the high-resolution image.

    Parameters
    ----------
    images : list of ndarray
        Low-resolution images.
    tf_matrices : list of (3, 3) ndarray
        Transformation matrices that warp the images to the reference
        image (usually ``images[0]``).
    scale : float
        The scale of the high-resolution reconstruction relative to the
        low-resolution frames.  Typically between 1 and 2.
    oshape : tuple of int
        Shape of the high-resolution reconstruction.

    """
    HH = [x.copy() for x in tf_matrices]
    for H in HH:
        H[:2, :] *= float(scale)

    return stack.with_transform(images, HH, oshape=oshape, order=3)
Exemple #4
0
import numpy as np

from supreme.io import load_vgg
from supreme.config import data_path
from supreme.register import stack

import matplotlib.pyplot as plt
from scipy.misc import imsave

import os, sys

scale = 1.5

if len(sys.argv) > 1:
    vgg_dir = sys.argv[1]
else:
    vgg_dir = os.path.join(data_path, 'vgg/sr_sequences/text')

ic = load_vgg(vgg_dir)

HH = [img.info['H'] for img in ic]
for H in HH:
    H[:2, :] *= scale
S = stack.with_transform(ic, HH, order=2)

imsave('vgg_stack.png', S)

plt.imshow(S, cmap=plt.cm.gray)
plt.show()