o
    :Î®c¥  ã                   @   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rt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")
    ÚRGBÚGRAYNé   z*Input image and trimap must have same size)r   ÚshapeÚ
ValueErrorr   r   r   r   )Ú
image_pathÚtrimap_pathÚcutout_pathÚimageÚtrimapÚalphaÚ
foregroundÚcutout© r   ú>/tmp/pip-target-vg8gfxp4/lib/python/pymatting/cutout/cutout.pyr      s   




r   N)	Úpymatting.util.utilr   r   r   Ú!pymatting.alpha.estimate_alpha_cfr   Ú+pymatting.foreground.estimate_foreground_mlr   r   r   r   r   r   Ú<module>   s    