Esempio n. 1
0
parser = OptionParser(usage=usage)
parser.add_option('-c', '--clip-box', dest='clip_box', nargs=4,
                  help='Clipping boundaries: x0, y0, x1, y1')
(options, args) = parser.parse_args()

if len(sys.argv) < 3:
    parser.print_help()
    sys.exit(0)

source_dir = sys.argv[-2]
target_dir = sys.argv[-1]

if os.path.exists(target_dir):
    raise ValueError("Output directory already exists.")

ic = load_vgg(source_dir)

image_dir = os.path.join(target_dir, 'png')
H_dir = os.path.join(target_dir, 'H')
os.mkdir(target_dir)
os.mkdir(image_dir)
os.mkdir(H_dir)

if not options.clip_box:
    x0, y0 = 0, 0
    y1, x1 = ic[0].shape
else:
    x0, y0, x1, y1 = [int(i) for i in options.clip_box]


for n, img in enumerate(ic):
Esempio n. 2
0
    warnings.warn("Using the 1-norm with L-BFGS-B may lead to non-convergence.")

d = options.__dict__
print "Input Parameters"
print "------------------------"
for k in d:
    print '%s: %s' % (k, d[k])
print "------------------------"

if len(parser.largs) == 1:
    vgg_dir = parser.largs[0]
else:
    parser.print_help()
    sys.exit(0)

ic = load_vgg(vgg_dir)

# Perform crude photometric registration
ref = ic[0].copy()
images = []
scale_offset = []
for i in range(len(ic)):
    scale = 1
    offset = 0

    if options.photo_adjust:
        img_warp = homography(ic[i], ic[i].info['H'])
        scale, offset = photometric_adjust(img_warp, ref)
        scale_offset.append((scale, offset))

    images.append(ic[i] * scale + offset)
Esempio n. 3
0
                  dest='clip_box',
                  nargs=4,
                  help='Clipping boundaries: x0, y0, x1, y1')
(options, args) = parser.parse_args()

if len(sys.argv) < 3:
    parser.print_help()
    sys.exit(0)

source_dir = sys.argv[-2]
target_dir = sys.argv[-1]

if os.path.exists(target_dir):
    raise ValueError("Output directory already exists.")

ic = load_vgg(source_dir)

image_dir = os.path.join(target_dir, 'png')
H_dir = os.path.join(target_dir, 'H')
os.mkdir(target_dir)
os.mkdir(image_dir)
os.mkdir(H_dir)

if not options.clip_box:
    x0, y0 = 0, 0
    y1, x1 = ic[0].shape
else:
    x0, y0, x1, y1 = [int(i) for i in options.clip_box]

for n, img in enumerate(ic):
    fn = os.path.join(image_dir, os.path.basename(source_dir) + \
Esempio n. 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()