Пример #1
0
def correlate2d(in1, in2, mode='full', boundary='fill', fillvalue=0):
    """Cross-correlate two 2-dimensional arrays.

  Description:

     Cross correlate in1 and in2 with output size determined by mode
     and boundary conditions determined by boundary and fillvalue.

  Inputs:

    in1 -- a 2-dimensional array.
    in2 -- a 2-dimensional array.
    mode -- a flag indicating the size of the output
            'valid'  (0): The output consists only of those elements that
                            do not rely on the zero-padding.
            'same'   (1): The output is the same size as the input centered
                            with respect to the 'full' output.
            'full'   (2): The output is the full discrete linear convolution
                            of the inputs. (*Default*)
    boundary -- a flag indicating how to handle boundaries
                'fill' : pad input arrays with fillvalue. (*Default*)
                'wrap' : circular boundary conditions.
                'symm' : symmetrical boundary conditions.
    fillvalue -- value to fill pad input arrays with (*Default* = 0)

  Outputs:  (out,)

    out -- a 2-dimensional array containing a subset of the discrete linear
           cross-correlation of in1 with in2.

    """
    val = _valfrommode(mode)
    bval = _bvalfromboundary(boundary)

    return sigtools._convolve2d(in1, in2, 0,val,bval,fillvalue)
Пример #2
0
def correlate2d(in1, in2, mode='full', boundary='fill', fillvalue=0):
    """Cross-correlate two 2-dimensional arrays.

  Description:

     Cross correlate in1 and in2 with output size determined by mode
     and boundary conditions determined by boundary and fillvalue.

  Inputs:

    in1 -- a 2-dimensional array.
    in2 -- a 2-dimensional array.
    mode -- a flag indicating the size of the output
            'valid'  (0): The output consists only of those elements that
                            do not rely on the zero-padding.
            'same'   (1): The output is the same size as the input centered
                            with respect to the 'full' output.
            'full'   (2): The output is the full discrete linear convolution
                            of the inputs. (*Default*)
    boundary -- a flag indicating how to handle boundaries
                'fill' : pad input arrays with fillvalue. (*Default*)
                'wrap' : circular boundary conditions.
                'symm' : symmetrical boundary conditions.
    fillvalue -- value to fill pad input arrays with (*Default* = 0)

  Outputs:  (out,)

    out -- a 2-dimensional array containing a subset of the discrete linear
           cross-correlation of in1 with in2.

    """
    val = _valfrommode(mode)
    bval = _bvalfromboundary(boundary)

    return sigtools._convolve2d(in1, in2, 0, val, bval, fillvalue)
Пример #3
0
def convolve2d(in1,
               in2,
               mode='full',
               boundary='fill',
               fillvalue=0,
               old_behavior=True):
    """Convolve two 2-dimensional arrays.

  Description:

     Convolve in1 and in2 with output size determined by mode and boundary
     conditions determined by boundary and fillvalue.

  Inputs:

    in1 -- a 2-dimensional array.
    in2 -- a 2-dimensional array.
    mode -- a flag indicating the size of the output
            'valid'  (0): The output consists only of those elements that
                            do not rely on the zero-padding.
            'same'   (1): The output is the same size as the input centered
                            with respect to the 'full' output.
            'full'   (2): The output is the full discrete linear convolution
                            of the inputs. (*Default*)
    boundary -- a flag indicating how to handle boundaries
                'fill' : pad input arrays with fillvalue. (*Default*)
                'wrap' : circular boundary conditions.
                'symm' : symmetrical boundary conditions.
    fillvalue -- value to fill pad input arrays with (*Default* = 0)

  Outputs:  (out,)

    out -- a 2-dimensional array containing a subset of the discrete linear
           convolution of in1 with in2.

    """
    if old_behavior:
        warnings.warn(DeprecationWarning(_SWAP_INPUTS_DEPRECATION_MSG))

    if old_behavior:
        warnings.warn(DeprecationWarning(_SWAP_INPUTS_DEPRECATION_MSG))
        if (product(np.shape(in2), axis=0) > product(np.shape(in1), axis=0)):
            temp = in1
            in1 = in2
            in2 = temp
            del temp
    else:
        if mode == 'valid':
            for d1, d2 in zip(np.shape(in1), np.shape(in2)):
                if not d1 >= d2:
                    raise ValueError(
                        "in1 should have at least as many items as in2 in " \
                        "every dimension for valid mode.")

    val = _valfrommode(mode)
    bval = _bvalfromboundary(boundary)

    return sigtools._convolve2d(in1, in2, 1, val, bval, fillvalue)
Пример #4
0
def convolve2d(in1, in2, mode='full', boundary='fill', fillvalue=0, old_behavior=True):
    """Convolve two 2-dimensional arrays.

  Description:

     Convolve in1 and in2 with output size determined by mode and boundary
     conditions determined by boundary and fillvalue.

  Inputs:

    in1 -- a 2-dimensional array.
    in2 -- a 2-dimensional array.
    mode -- a flag indicating the size of the output
            'valid'  (0): The output consists only of those elements that
                            do not rely on the zero-padding.
            'same'   (1): The output is the same size as the input centered
                            with respect to the 'full' output.
            'full'   (2): The output is the full discrete linear convolution
                            of the inputs. (*Default*)
    boundary -- a flag indicating how to handle boundaries
                'fill' : pad input arrays with fillvalue. (*Default*)
                'wrap' : circular boundary conditions.
                'symm' : symmetrical boundary conditions.
    fillvalue -- value to fill pad input arrays with (*Default* = 0)

  Outputs:  (out,)

    out -- a 2-dimensional array containing a subset of the discrete linear
           convolution of in1 with in2.

    """
    if old_behavior:
        warnings.warn(DeprecationWarning(_SWAP_INPUTS_DEPRECATION_MSG))

    if old_behavior:
        warnings.warn(DeprecationWarning(_SWAP_INPUTS_DEPRECATION_MSG))
        if (product(np.shape(in2),axis=0) > product(np.shape(in1),axis=0)):
            temp = in1
            in1 = in2
            in2 = temp
            del temp
    else:
        if mode == 'valid':
            for d1, d2 in zip(np.shape(in1), np.shape(in2)):
                if not d1 >= d2:
                    raise ValueError(
                        "in1 should have at least as many items as in2 in " \
                        "every dimension for valid mode.")

    val = _valfrommode(mode)
    bval = _bvalfromboundary(boundary)

    return sigtools._convolve2d(in1,in2,1,val,bval,fillvalue)
Пример #5
0
def convolve2d(in1, in2, mode='full', boundary='fill', fillvalue=0):
    """Convolve two 2-dimensional arrays.

    Convolve `in1` and `in2` with output size determined by mode and boundary
    conditions determined by `boundary` and `fillvalue`.

    Parameters
    ----------
    in1, in2 : ndarray
        Two-dimensional input arrays to be convolved.
    mode: str, optional
        A string indicating the size of the output:

        ``valid`` : the output consists only of those elements that do not
           rely on the zero-padding.

        ``same`` : the output is the same size as ``in1`` centered
           with respect to the 'full' output.

        ``full`` : the output is the full discrete linear cross-correlation
           of the inputs. (Default)

    boundary : str, optional
        A flag indicating how to handle boundaries:

          - 'fill' : pad input arrays with fillvalue. (default)
          - 'wrap' : circular boundary conditions.
          - 'symm' : symmetrical boundary conditions.

    fillvalue : scalar, optional
        Value to fill pad input arrays with. Default is 0.

    Returns
    -------
    out : ndarray
        A 2-dimensional array containing a subset of the discrete linear
        convolution of `in1` with `in2`.

    """
    if mode == 'valid':
        for d1, d2 in zip(np.shape(in1), np.shape(in2)):
            if not d1 >= d2:
                raise ValueError(
                    "in1 should have at least as many items as in2 in " \
                    "every dimension for valid mode.")

    val = _valfrommode(mode)
    bval = _bvalfromboundary(boundary)

    return sigtools._convolve2d(in1, in2, 1, val, bval, fillvalue)
Пример #6
0
def convolve2d(in1, in2, mode='full', boundary='fill', fillvalue=0):
    """Convolve two 2-dimensional arrays.

    Convolve `in1` and `in2` with output size determined by mode and boundary
    conditions determined by `boundary` and `fillvalue`.

    Parameters
    ----------
    in1, in2 : ndarray
        Two-dimensional input arrays to be convolved.
    mode: str, optional
        A string indicating the size of the output:

        ``valid`` : the output consists only of those elements that do not
           rely on the zero-padding.

        ``same`` : the output is the same size as the largest input centered
           with respect to the 'full' output.

        ``full`` : the output is the full discrete linear cross-correlation
           of the inputs. (Default)

    boundary : str, optional
        A flag indicating how to handle boundaries:

          - 'fill' : pad input arrays with fillvalue. (default)
          - 'wrap' : circular boundary conditions.
          - 'symm' : symmetrical boundary conditions.

    fillvalue : scalar, optional
        Value to fill pad input arrays with. Default is 0.

    Returns
    -------
    out : ndarray
        A 2-dimensional array containing a subset of the discrete linear
        convolution of `in1` with `in2`.

    """
    if mode == 'valid':
        for d1, d2 in zip(np.shape(in1), np.shape(in2)):
            if not d1 >= d2:
                raise ValueError(
                    "in1 should have at least as many items as in2 in " \
                    "every dimension for valid mode.")

    val = _valfrommode(mode)
    bval = _bvalfromboundary(boundary)

    return sigtools._convolve2d(in1, in2, 1, val, bval, fillvalue)
Пример #7
0
def correlate2d(in1, in2, mode='full', boundary='fill', fillvalue=0, old_behavior=True):
    """Cross-correlate two 2-dimensional arrays.

    Cross correlate in1 and in2 with output size determined by mode and
    boundary conditions determined by `boundary` and `fillvalue`.

    Parameters
    ----------
    in1, in2 : ndarray
        Two-dimensional input arrays to be convolved.
    mode: str, optional
        A string indicating the size of the output:

        ``valid`` : the output consists only of those elements that do not
           rely on the zero-padding.

        ``same`` : the output is the same size as the largest input centered
           with respect to the 'full' output.

        ``full`` : the output is the full discrete linear cross-correlation
           of the inputs. (Default)

    boundary : str, optional
        A flag indicating how to handle boundaries:

          - 'fill' : pad input arrays with fillvalue. (default)
          - 'wrap' : circular boundary conditions.
          - 'symm' : symmetrical boundary conditions.

    fillvalue : scalar, optional
        Value to fill pad input arrays with. Default is 0.

    Returns
    -------
    out : ndarray
        A 2-dimensional array containing a subset of the discrete linear
        cross-correlation of `in1` with `in2`.

    """
    if old_behavior:
        warnings.warn(DeprecationWarning(_SWAP_INPUTS_DEPRECATION_MSG))
    val = _valfrommode(mode)
    bval = _bvalfromboundary(boundary)

    return sigtools._convolve2d(in1, in2, 0,val,bval,fillvalue)
Пример #8
0
def correlate2d(in1, in2, mode='full', boundary='fill', fillvalue=0):
    """Cross-correlate two 2-dimensional arrays.

    Cross correlate in1 and in2 with output size determined by mode and
    boundary conditions determined by `boundary` and `fillvalue`.

    Parameters
    ----------
    in1, in2 : ndarray
        Two-dimensional input arrays to be convolved.
    mode: str, optional
        A string indicating the size of the output:

        ``valid`` : the output consists only of those elements that do not
           rely on the zero-padding.

        ``same`` : the output is the same size as ``in1`` centered
           with respect to the 'full' output.

        ``full`` : the output is the full discrete linear cross-correlation
           of the inputs. (Default)

    boundary : str, optional
        A flag indicating how to handle boundaries:

          - 'fill' : pad input arrays with fillvalue. (default)
          - 'wrap' : circular boundary conditions.
          - 'symm' : symmetrical boundary conditions.

    fillvalue : scalar, optional
        Value to fill pad input arrays with. Default is 0.

    Returns
    -------
    out : ndarray
        A 2-dimensional array containing a subset of the discrete linear
        cross-correlation of `in1` with `in2`.

    """
    val = _valfrommode(mode)
    bval = _bvalfromboundary(boundary)

    return sigtools._convolve2d(in1, in2, 0, val, bval, fillvalue)