Пример #1
0
# Xtv0 = calculate2dTV(X, 0)

# assert abs(X - Xtv0).mean() <= 1e-4, abs(X - Xtv0).mean()

lambdas = np.linspace(0.1, 1, 50)

Xtv_2 = calculate2dTVPath(X, lambdas)
print "Done calculating Regpath Version."

# Get the first round
Xtv_1 = np.empty( (lambdas.size, X.shape[0], X.shape[1]) )

for i, lm in enumerate(lambdas):
    print "Calculating %d/%d (lambda = %1.5f)" % ((i + 1), len(lambdas), lm)
    Xtv_1[i,:,:] = calculate2dTV(X, lm)

print "Done calculating indivdual models."


def plotRegPath(a, Xtv):

    xc, yc = 0, 0

    col = []
    
    ymin, ymax = 0,0

    for xi, yi in product(range(0, Xtv.shape[1]), range(0, Xtv.shape[2])):
        
        y = Xtv[:,xi, yi]
Пример #2
0
#image_file = "benchmarks/images/sanity.png"
image_file = "benchmarks/images/truffles-small.png"
image_file = "benchmarks/images/branches.png"

Xo = imread(image_file)

if not Xo.size:
    raise IOError("Error loading image %s." % image_file)

print "Image file %s loaded." % image_file

X = (Xo.mean(axis=2) / Xo.max())

X -= X.mean()
X /= X.std()

Xtv = calculate2dTV(X, lm)

Xtv -= X.mean()
Xtv /= X.std()

f = figure()
a = f.add_subplot(121)
a.imshow(X, interpolation='nearest')

a = f.add_subplot(122)
a.imshow(Xtv,  interpolation='nearest')

show()