예제 #1
0
def comparePixelExpr(pixelExpr1, pixelExpr2):
    zoom = getZoom(pixelExpr1)
    assert zoom == getZoom(pixelExpr2)
    mismatchCount = 0
    for case, (expr1, expr2) in enumerate(zip(pixelExpr1, pixelExpr2)):
        if expr1 != expr2:
            binStr = bin(case)[2:].zfill(12)
            print('case: %d (%s)' % (case, ' '.join(binStr[i:i + 4]
                                                    for i in range(0, 12, 4))))
            for sy in range(zoom):
                matrices = []
                for sx in range(zoom):
                    subPixel = sy * zoom + sx
                    subExpr1 = expr1[subPixel]
                    subExpr2 = expr2[subPixel]
                    rows = []
                    for ny in range(3):
                        rows.append(
                            '%s   %s %s' %
                            (formatWeights(subExpr1[ny * 3:(ny + 1) * 3]),
                             '.' if subExpr1 == subExpr2 else '!',
                             formatWeights(subExpr2[ny * 3:(ny + 1) * 3])))
                    matrices.append(rows)
                for ny in range(3):
                    print('  %s' % '       '.join(matrices[sx][ny]
                                                  for sx in range(zoom)))
                print()
            mismatchCount += 1
    print('Number of mismatches: %d' % mismatchCount)
예제 #2
0
def comparePixelExpr(pixelExpr1, pixelExpr2):
	zoom = getZoom(pixelExpr1)
	assert zoom == getZoom(pixelExpr2)
	mismatchCount = 0
	for case, (expr1, expr2) in enumerate(izip(pixelExpr1, pixelExpr2)):
		if expr1 != expr2:
			binStr = bin(case)[2 : ].zfill(12)
			print 'case: %d (%s)' % (
				case,
				' '.join(binStr[i : i + 4] for i in range(0, 12, 4))
				)
			for sy in xrange(zoom):
				matrices = []
				for sx in xrange(zoom):
					subPixel = sy * zoom + sx
					subExpr1 = expr1[subPixel]
					subExpr2 = expr2[subPixel]
					rows = []
					for ny in xrange(3):
						rows.append('%s   %s %s' % (
							formatWeights(subExpr1[ny * 3 : (ny + 1) * 3]),
							'.' if subExpr1 == subExpr2 else '!',
							formatWeights(subExpr2[ny * 3 : (ny + 1) * 3])
							))
					matrices.append(rows)
				for ny in xrange(3):
					print '  %s' % '       '.join(
						matrices[sx][ny]
						for sx in xrange(zoom)
						)
				print
			mismatchCount += 1
	print 'Number of mismatches: %d' % mismatchCount
예제 #3
0
def extractTopLeftQuadrant(pixelExpr):
    zoom = getZoom(pixelExpr)
    quadrantWidth = (zoom + 1) // 2
    quadrantMap = [
        qy * zoom + qx for qy in range(quadrantWidth)
        for qx in range(quadrantWidth)
    ]
    for expr in [[expr[subPixel] for subPixel in quadrantMap]
                 for expr in pixelExpr]:
        for weights in expr:
            for neighbour in (2, 5, 6, 7, 8):
                assert weights[neighbour] == 0, weights
    return [[
        extractTopLeftWeights(expr[subPixel]) for subPixel in quadrantMap
    ] for expr in pixelExpr]
예제 #4
0
def extractTopLeftQuadrant(pixelExpr):
	zoom = getZoom(pixelExpr)
	quadrantWidth = (zoom + 1) / 2
	quadrantMap = [
		qy * zoom + qx
		for qy in xrange(quadrantWidth)
		for qx in xrange(quadrantWidth)
		]
	for expr in [
		[ expr[subPixel] for subPixel in quadrantMap ]
		for expr in pixelExpr
		]:
		for weights in expr:
			for neighbour in (2, 5, 6, 7, 8):
				assert weights[neighbour] == 0, weights
	return [
		[ extractTopLeftWeights(expr[subPixel]) for subPixel in quadrantMap ]
		for expr in pixelExpr
		]