a
    d                     @   s*   d dl Zd dlmZ dddZdd ZdS )	    N)	bgr2ycbcrHWCc                 C   sH   |dvrt d| dt| jdkr.| d } |dkrD| ddd} | S )	a  Reorder images to 'HWC' order.

    If the input_order is (h, w), return (h, w, 1);
    If the input_order is (c, h, w), return (h, w, c);
    If the input_order is (h, w, c), return as it is.

    Args:
        img (ndarray): Input image.
        input_order (str): Whether the input order is 'HWC' or 'CHW'.
            If the input image shape is (h, w), input_order will not have
            effects. Default: 'HWC'.

    Returns:
        ndarray: reordered image.
    )r   CHWzWrong input_order z,. Supported input_orders are 'HWC' and 'CHW'   .Nr      r   )
ValueErrorlenshapeZ	transpose)imgZinput_order r   d/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/basicsr/metrics/metric_util.pyreorder_image   s    r   c                 C   sD   |  tjd } | jdkr<| jd dkr<t| dd} | d } | d S )zChange to Y channel of YCbCr.

    Args:
        img (ndarray): Images with range [0, 255].

    Returns:
        (ndarray): Images with range [0, 255] (float type) without round.
    g     o@   r   T)Zy_onlyr   )Zastypenpfloat32ndimr
   r   )r   r   r   r   to_y_channel    s
    	r   )r   )numpyr   Zbasicsr.utilsr   r   r   r   r   r   r   <module>   s   
