How to use the pyamg.solve function in pyamg

To help you get started, we’ve selected a few pyamg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fbessho / PyPoi / pypoi / poissonblending.py View on Github external
# get subimages
        t = img_target[region_target[0]:region_target[2], region_target[1]:region_target[3], num_layer]
        s = img_source[region_source[0]:region_source[2], region_source[1]:region_source[3], num_layer]
        t = t.flatten()
        s = s.flatten()

        # create b
        b = P * s
        for y in range(region_size[0]):
            for x in range(region_size[1]):
                if not img_mask[y, x]:
                    index = x + y * region_size[1]
                    b[index] = t[index]

        # solve Ax = b
        x = pyamg.solve(A, b, verb=False, tol=1e-10)

        # assign x to target image
        x = np.reshape(x, region_size)
        x[x > 255] = 255
        x[x < 0] = 0
        x = np.array(x, img_target.dtype)
        img_target[region_target[0]:region_target[2], region_target[1]:region_target[3], num_layer] = x

    return img_target
github human-analysis / RankGAN / evaluation.py View on Github external
# get subimages
        t = img_target[num_layer, region_target[0]:region_target[2],region_target[1]:region_target[3]]
        s = img_source[num_layer, region_source[0]:region_source[2], region_source[1]:region_source[3]]
        t = t.flatten()
        s = s.flatten()

        # create b
        b = P * s
        for y in range(region_size[0]):
            for x in range(region_size[1]):
                if not img_mask[y,x]:
                    index = x+y*region_size[1]
                    b[index] = t[index]

        # solve Ax = b
        x = pyamg.solve(A,b,verb=False,tol=1e-10)

        # assign x to target image
        x = np.reshape(x, region_size)
        x[x>1] = 1
        x[x<-1] = -1
        x = np.array(x, img_target.dtype)
        img_target[num_layer, region_target[0]:region_target[2],region_target[1]:region_target[3]] = x

    return img_target
github cemagg / sucem-fem / sucemfem / Utilities / LinalgSolvers.py View on Github external
def _call_solver (self):
        """Solves the linear system (self._A)x = self._b and returns the solution vector.
        
        @return: The solution to the linear system.
        """
        import pyamg
        x = pyamg.solve ( self._A, self._b, verb=True, tol=1e-8, maxiter=800 )
        return x, 0
github alyssaq / face_morpher / facemorpher / blender.py View on Github external
region_target[1]:region_target[3], num_layer]
    s = img_source[region_source[0]:region_source[2],
                   region_source[1]:region_source[3], num_layer]
    t = t.flatten()
    s = s.flatten()

    # create b
    b = poisson_mat * s
    for y in range(region_size[0]):
      for x in range(region_size[1]):
        if not img_mask[y, x]:
          index = x + y * region_size[1]
          b[index] = t[index]

    # solve Ax = b
    x = pyamg.solve(coff_mat, b, verb=False, tol=1e-10)

    # assign x to target image
    x = np.reshape(x, region_size)
    x[x > 255] = 255
    x[x < 0] = 0
    x = np.array(x, img_target.dtype)
    img_target[region_target[0]:region_target[2],
               region_target[1]:region_target[3], num_layer] = x

  return img_target