def convert(self, from_, to, what):
        """
        Convert image or color "what" from "from_" colorpace to "to"
        colorspace.  E.g.: ``convert("rgb", "hsv", X)``, where X is a
        numpy dstack or a color tuple.
        """

        if(from_.lower()==to.lower()):
            return what

        # Check if there exist an optimized function that performs
        # from_to_to conversion
        direct_conversion = '%s_to_%s'%(from_.lower(),to.lower())
        if( hasattr(self, direct_conversion ) ):
            fn = getattr(self, direct_conversion)
            return fn(what)

        from_to_xyz = getattr(self, '%s_to_xyz'%(from_.lower()) )
        xyz_to_to = getattr(self, 'xyz_to_%s'%(to.lower()) )

        return xyz_to_to( from_to_xyz(what) )
def convert ( self , from_ , to , what ) : if ( from_ . lower ( ) == to . lower ( ) ) : return what direct_conversion = '%s_to_%s' % ( from_ . lower ( ) , to . lower ( ) ) if ( hasattr ( self , direct_conversion ) ) : fn = getattr ( self , direct_conversion ) return fn ( what ) from_to_xyz = getattr ( self , '%s_to_xyz' % ( from_ . lower ( ) ) ) xyz_to_to = getattr ( self , 'xyz_to_%s' % ( to . lower ( ) ) ) return xyz_to_to ( from_to_xyz ( what ) )
Convert image or color "what" from "from_" colorpace to "to"
        colorspace.  E.g.: ``convert("rgb", "hsv", X)``, where X is a
        numpy dstack or a color tuple.