def adapt_rgb(apply_to_rgb):
 def decorator(image_filter):
  @functools.wraps(image_filter)
  def image_filter_adapted(image, *args, **kwargs):
   if is_rgb_like(image):
    return apply_to_rgb(image_filter, image, *args, **kwargs)
   else:
    return image_filter(image, *args, **kwargs)
  return image_filter_adapted
 return decorator

def adapt_rgb ( apply_to_rgb ) : def decorator ( image_filter ) : @ functools . wraps ( image_filter ) def image_filter_adapted ( image , * args , ** kwargs ) : if is_rgb_like ( image ) : return apply_to_rgb ( image_filter , image , * args , ** kwargs ) else : return image_filter ( image , * args , ** kwargs ) return image_filter_adapted return decorator
return decorator that adapts to rgb images to a gray-scale filter .