§
    +ÁôgÓ  ã                   ó"   — d dl mZ d dlZdd„ZdS )é    )Útrimap_splitNç      Y@Fc                 ó  — |j         dd…         \  }}t          |¦  «        \  }}}}	||z  }
||z  }t          j                             |
¦  «        }| |z   }|                     ¦   «         }|                     ¦   «          |r|||
fS ||fS )a  This function constructs a linear system from a matting Laplacian by
    constraining the foreground and background pixels with a diagonal matrix
    `C` to values in the right-hand-side vector `b`. The constraints are
    weighted by a factor :math:`\lambda`. The linear system is given as

    .. math::

      A = L + \lambda C,

    where :math:`C=\mathop{Diag}(c)` having :math:`c_i = 1` if pixel i is known
    and :math:`c_i = 0` otherwise.
    The right-hand-side :math:`b` is a vector with entries :math:`b_i = 1` is
    pixel is is a foreground pixel and :math:`b_i = 0` otherwise.


    Parameters
    ----------
    L: scipy.sparse.spmatrix
        Laplacian matrix, e.g. calculated with :code:`lbdm_laplacian` function
    trimap: numpy.ndarray
        Trimap with shape :math:`h\times w`
    lambda_value: float
        Constraint penalty, defaults to 100
    return_c: bool
        Whether to return the constraint matrix `C`, defaults to False

    Returns
    -------
    A: scipy.sparse.spmatrix
        Matrix describing the system of linear equations
    b: numpy.ndarray
        Vector describing the right-hand side of the system
    C: numpy.ndarray
        Vector describing the diagonal entries of the matrix `C`, only returned
        if `return_c` is set to True
    Né   )Úshaper   ÚscipyÚsparseÚdiagsÚtocsrÚsum_duplicates)ÚLÚtrimapÚlambda_valueÚreturn_cÚhÚwÚis_fgÚis_bgÚis_knownÚ
is_unknownÚcÚbÚCÚAs                 úf/var/www/html/bac/bac_backend/python/env/lib/python3.11/site-packages/pymatting/laplacian/laplacian.pyÚmake_linear_systemr      sœ   € ðJ Œ<˜˜˜Ô�D€A€qå)5°fÑ)=Ô)=Ñ&€Eˆ5�(˜Jà�xÑ€AØ�uÑ€AåŒ×Ò˜1ÑÔ€Aà	ˆA‰€Aà	�Š‰	Œ	€Aà×ÒÑÔÐàð Ø�!�Qˆwˆàˆaˆ4€Kó    )r   F)Úpymatting.util.utilr   Úscipy.sparser   r   © r   r   ú<module>r!      sA   ðØ ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø Ð Ð Ð ð7ð 7ð 7ð 7ð 7ð 7r   