U
    !?h                     @   s8   d dl mZmZmZ d dlmZ d dlmZ dd ZdS )    )
load_image
save_imagestack_images)estimate_alpha_cf)estimate_foreground_mlc                 C   sd   t | d}t |d}|jdd |jdd kr8tdt||}t||}t||}t|| dS )a  
    Generate a cutout image from an input image and an input trimap.
    This method is using closed-form alpha matting as proposed by :cite:`levin2007closed` and multi-level foreground extraction :cite:`germer2020multilevel`.

    Parameters
    ----------
    image_path: str
        Path of input image
    trimap_path: str
        Path of input trimap
    cutout_path: str
        Path of output cutout image

    Example
    -------
    >>> cutout("../data/lemur.png", "../data/lemur_trimap.png", "lemur_cutout.png")
    RGBZGRAYN   z*Input image and trimap must have same size)r   shape
ValueErrorr   r   r   r   )Z
image_pathZtrimap_pathZcutout_pathimageZtrimapalpha
foregroundcutout r   I/var/www/html/venv/lib/python3.8/site-packages/pymatting/cutout/cutout.pyr      s    




r   N)	Zpymatting.util.utilr   r   r   Z!pymatting.alpha.estimate_alpha_cfr   Z+pymatting.foreground.estimate_foreground_mlr   r   r   r   r   r   <module>   s   