Beispiel #1
0
 def eit_operator(self,input, scale, output = None, mode = "reflect", cval = 0.0):
     """Calculate a multidimensional laplace filter using an estimation
     for the second derivative based on differences.
     """
     def derivative2(input, axis, output, mode, cval):
         return correlate1d(input, scale*np.array([1, -2, 1]), axis, output, mode, cval, 0)
     return generic_laplace(input, derivative2, output, mode, cval)
def _scc_single(GT, P, win, ws):
    def _scc_filter(inp, axis, output, mode, cval):
        return correlate(inp, win, output, mode, cval, 0)

    GT_hp = generic_laplace(GT.astype(np.float64), _scc_filter)
    P_hp = generic_laplace(P.astype(np.float64), _scc_filter)
    win = fspecial(Filter.UNIFORM, ws)
    sigmaGT_sq, sigmaP_sq, sigmaGT_P = _get_sigmas(GT_hp, P_hp, win)

    sigmaGT_sq[sigmaGT_sq < 0] = 0
    sigmaP_sq[sigmaP_sq < 0] = 0

    den = np.sqrt(sigmaGT_sq) * np.sqrt(sigmaP_sq)
    idx = (den == 0)
    den = _replace_value(den, 0, 1)
    scc = sigmaGT_P / den
    scc[idx] = 0
    return scc
Beispiel #3
0
def gaussian_laplace(input, sigma):

    input = np.asarray(input)

    def derivative2(input, axis, output, mode, cval, *extra_arguments,
                    **extra_keywords):
        order = [0] * input.ndim
        order[axis] = 2
        return gaussian_filter(input, sigma, order)

    return generic_laplace(input, derivative2, extra_arguments=(sigma, ))
Beispiel #4
0
    def eit_operator(self,
                     input,
                     scale,
                     output=None,
                     mode="reflect",
                     cval=0.0):
        """Calculate a multidimensional laplace filter using an estimation
        for the second derivative based on differences.
        """
        def derivative2(input, axis, output, mode, cval):
            return correlate1d(input, scale * np.array([1, -2, 1]), axis,
                               output, mode, cval, 0)

        return generic_laplace(input, derivative2, output, mode, cval)
def do_scipy_laplace():
    image = cv2.imread(f"sampled_images_interpolated.png")
    image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)

    def derivative2(input, axis, output, mode, cval):
        return correlate1d(input, [-1, 2, -1], axis, output, mode, cval, 0)

    image2 = generic_laplace(image, derivative2, output=None, mode="reflect", cval=0.0)

    cv2.imwrite("scipy_laplace.png", image2)
    from scipy import ndimage, misc

    ascent = misc.ascent()
    result = ndimage.laplace(ascent)

    cv2.imwrite("ascent.png", ascent)
    cv2.imwrite("result.png", result)