Example #1
0
def run(logger, args, extra_argv=None):
    import matplotlib.pyplot as plt
    import matplotlib.patches as patches

    img_array = np.zeros((args.iH, args.iW), dtype="i1")
    fig = plt.figure()
    ax = fig.add_subplot(111, aspect='equal')
    ax.add_patch(patches.Rectangle((0, 0), args.iW, args.iH, alpha=IMG_ALPHA))
    mx = max(1, .05 * args.iW)
    my = max(1, .05 * args.iH)
    ax.axis([-mx, args.iW + mx, -my, args.iH + my])
    for i, j, tile in gen_tiles(img_array,
                                w=args.W,
                                h=args.H,
                                dx=args.x,
                                dy=args.y,
                                ox=args.offset_x,
                                oy=args.offset_y):
        h, w = tile.shape
        ax.add_patch(patches.Rectangle((j, i), w, h, alpha=TILE_ALPHA))
        logger.debug("%r", (j, i, w, h))
    ax.invert_yaxis()
    if max(args.iW, args.iH) <= MAX_SMALL_SIZE:
        ax.set_xticks(xrange(args.iW + 1))
        ax.set_yticks(xrange(args.iH + 1))
        ax.grid()
    logger.info("writing to %r" % (args.out_fn, ))
    fig.savefig(args.out_fn)
Example #2
0
def run(logger, args, extra_argv=None):
    import matplotlib.pyplot as plt
    import matplotlib.patches as patches

    img_array = np.zeros((args.iH, args.iW), dtype="i1")
    fig = plt.figure()
    ax = fig.add_subplot(111, aspect='equal')
    ax.add_patch(patches.Rectangle((0, 0), args.iW, args.iH, alpha=IMG_ALPHA))
    mx = max(1, .05 * args.iW)
    my = max(1, .05 * args.iH)
    ax.axis([-mx, args.iW + mx, -my, args.iH + my])
    for i, j, tile in gen_tiles(img_array, w=args.W, h=args.H,
                                dx=args.x, dy=args.y,
                                ox=args.offset_x, oy=args.offset_y):
        h, w = tile.shape
        ax.add_patch(patches.Rectangle((j, i), w, h, alpha=TILE_ALPHA))
        logger.debug("%r", (j, i, w, h))
    ax.invert_yaxis()
    if max(args.iW, args.iH) <= MAX_SMALL_SIZE:
        ax.set_xticks(xrange(args.iW + 1))
        ax.set_yticks(xrange(args.iH + 1))
        ax.grid()
    logger.info("writing to %r" % (args.out_fn,))
    fig.savefig(args.out_fn)
Example #3
0
 def runTest(self):
     for kwargs, slices in self.cases:
         tiles = list(gen_tiles(self.a, **kwargs))
         self.assertEqual(len(tiles), len(slices))
         for (i, j, t), (i1, i2, j1, j2) in izip(tiles, slices):
             self.assertTrue(np.array_equal(t, self.a[i1: i2, j1: j2]))
Example #4
0
 def runTest(self):
     for kwargs, slices in self.cases:
         tiles = list(gen_tiles(self.a, **kwargs))
         self.assertEqual(len(tiles), len(slices))
         for (i, j, t), (i1, i2, j1, j2) in izip(tiles, slices):
             self.assertTrue(np.array_equal(t, self.a[i1: i2, j1: j2]))