Exemplo n.º 1
0
def _launch_quilt(debug, final_path, src, **kwargs):
    """
    Launches quilt process with the parsed arguments.
    """

    multi_proc = kwargs.pop('multiprocess')

    # ------------- quilt --------------

    qs = time.time()
    log.info('Quilt started at {0}'.format(time.strftime("%H:%M:%S")))

    try:
        # compute quilting
        Quilt.debug = debug
        q = Quilt(src, **kwargs)
        if multi_proc:
            q.optimized_compute()
        else:
            q.compute()

        # get the result
        result = q.get_result()
        if debug:
            show(result)
        save(result, final_path)

    except ValueError as err:
        log.error(err.message)
        return

    t = (time.time() - qs) / 60
    log.debug('Quilt took {0:0.6f} minutes'.format(t))
    log.info('End {0}'.format(time.strftime("%H:%M:%S")))
Exemplo n.º 2
0
    def test_chessboard_multiproc(self):
        """
        Test optimized_compute method on the chessboard matrix.
        Test the final result is still a chessboard matrix with tiles of the
        same size as the ones in the input.
        """
        q = Quilt(np.float64(self.chessboard),
                  output_size=[16, 16],
                  tilesize=4,
                  overlap=2,
                  error=0,
                  big_tilesize=8,
                  big_overlap=3,
                  constraint_start=True)
        q.debug = False
        q.optimized_compute()
        result = q.get_result()[0]

        # check the dimension
        self.assertEqual((16, 16, 3), result.shape)
        assert_array_equal(result[:, :, 0], result[:, :, 1], result[:, :, 2])

        # check the values
        result = result[:, :, 0]
        expected = np.asarray([[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1],
                               [0, 0, 1, 1]])
        for i in xrange(0, result.shape[0] - 4, 4):
            for j in xrange(0, result.shape[1] - 4, 4):
                patch = result[i:i + 4, j:j + 4]
                assert_array_equal(expected, patch)