Created
April 25, 2014 14:10
-
-
Save jschwinger233/11290890 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Apr 26 19:36:04 2014 | |
@author: Administrator | |
""" | |
import heapq | |
import numpy as np | |
from scipy.misc import imread | |
import matplotlib.pyplot as plt | |
import sys | |
sys.path.extend('F:\\点我,就是我\\cumcm2013\\附件3') | |
n, h, w = 209, 180, 72 | |
pic = np.array([imread('%03d.bmp' % i) for i in xrange(n)], dtype=np.uint8) | |
cap = np.zeros((5*n+2, 5*n+2), dtype=np.uint8) | |
cost = np.zeros((5*n+2, 5*n+2), dtype=np.uint32) | |
par = np.arange(1, 5*n+1, 5).reshape((-1, 1)) | |
sin = np.arange(2, 5*n+1, 5).reshape((-1, 1)) + np.arange(2) | |
sout = np.arange(4, 5*n+1, 5).reshape((-1, 1)) + np.arange(2) | |
cap[sin, par] = 1 | |
cap[par, sout] = 1 | |
cap[0, sin] = 1 # s to in | |
cap[sout, -1] = 1 # out to t | |
cap[sout, sin] = 1 | |
for i in xrange(n): | |
cost[5*i+4, 2:-1:5] = np.sum((pic[i, -1] - pic[:, 0]) ** 2, axis=1) | |
cost[5*i+4, 3:-1:5] = np.sum((pic[i, :, -1] - pic[:, :, 0]) ** 2, axis=1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment