o
    :ήc	                     @   sV   d dl Z d dlZddlmZ ddlmZ g dZdddZd	d
 Z	dd Z
dd ZdS )    N   )color)_convert)	adapt_rgb	hsv_valueeach_channelc                 C   s   | j dko| j| dv S )zReturn True if the image *looks* like it's RGB.

    This function should not be public because it is only intended to be used
    for functions that don't accept volumes as input, since checking an image's
    shape is fragile.
       )r	      )ndimshape)imagechannel_axis r   >/tmp/pip-target-vg8gfxp4/lib/python/skimage/color/adapt_rgb.pyis_rgb_like   s   r   c                    s    fdd}|S )a  Return decorator that adapts to RGB images to a gray-scale filter.

    This function is only intended to be used for functions that don't accept
    volumes as input, since checking an image's shape is fragile.

    Parameters
    ----------
    apply_to_rgb : function
        Function that returns a filtered image from an image-filter and RGB
        image. This will only be called if the image is RGB-like.
    c                    s   t   fdd}|S )Nc                    s6   t | r | g|R i |S | g|R i |S )N)r   )r   argskwargs)apply_to_rgbimage_filterr   r   image_filter_adapted#   s   z:adapt_rgb.<locals>.decorator.<locals>.image_filter_adapted)	functoolswraps)r   r   r   )r   r   	decorator"   s   zadapt_rgb.<locals>.decoratorr   )r   r   r   r   r   r      s   r   c                 O   sx   t |ddddddf }|dddddf  }| |g|R i |}t||j|dddddf< t |S )aL  Return color image by applying `image_filter` on HSV-value of `image`.

    Note that this function is intended for use with `adapt_rgb`.

    Parameters
    ----------
    image_filter : function
        Function that filters a gray-scale image.
    image : array
        Input image. Note that RGBA images are treated as RGB.
    Nr	   r   )r   rgb2hsvcopyr   dtypehsv2rgb)r   r   r   r   hsvvaluer   r   r   r   -   s
    
r   c                    s.    fddt |ddD }t j|ddS )a!  Return color image by applying `image_filter` on channels of `image`.

    Note that this function is intended for use with `adapt_rgb`.

    Parameters
    ----------
    image_filter : function
        Function that filters a gray-scale image.
    image : array
        Input image.
    c                    s"   g | ]}|g R i qS r   r   ).0cr   r   r   r   r   
<listcomp>M   s    z each_channel.<locals>.<listcomp>r   r   )axis)npmoveaxisstack)r   r   r   r   c_newr   r#   r   r   A   s   r   )r   )r   numpyr&    r   
util.dtyper   __all__r   r   r   r   r   r   r   r   <module>   s    

