QMF

A Quadrature Mirror Filter (QMF) is a pair of filters that decompose a signal into two subbands (low-pass and high-pass) and allow for perfect reconstruction of the original signal.

This function generates the high-pass filter coefficients from the provided low-pass filter coefficients.

Excel Usage

=QMF(hk)
  • hk (list[list], required): Coefficients of the low-pass filter (Excel range).

Returns (list[list]): A 1D array (as a row) of high-pass filter coefficients.

Example 1: Simple QMF

Inputs:

hk
1 1

Excel formula:

=QMF({1,1})

Expected output:

Result
1 -1

Python Code

Show Code
import numpy as np
from scipy.signal import qmf as scipy_qmf

def qmf(hk):
    """
    Return a Quadrature Mirror Filter (QMF) from low-pass coefficients.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.qmf.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        hk (list[list]): Coefficients of the low-pass filter (Excel range).

    Returns:
        list[list]: A 1D array (as a row) of high-pass filter coefficients.
    """
    try:
        def to_1d(v):
            if isinstance(v, list):
                return np.array([float(x) for row in v for x in row])
            return np.array([float(v)])

        hk_arr = to_1d(hk)
        result = scipy_qmf(hk_arr)
        return [result.tolist()]
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Coefficients of the low-pass filter (Excel range).