menpo/visualize/image.py
def glyph(pixels, vectors_block_size=10, use_negative=False, channels=None):
    r"""
    Create glyph of a feature image. If `pixels` have negative values, the
    `use_negative` flag controls whether there will be created a glyph of
    both positive and negative values concatenated the one on top of the
    other.

    Parameters
    ----------
    pixels : `ndarray`
        The input image's pixels.

    vectors_block_size: int
        Defines the size of each block with vectors of the glyph image.

    use_negative: bool
        Defines whether to take into account possible negative values of
        feature_data.
    """
    # first, choose the appropriate channels
    if channels is None:
        pixels = pixels[..., :4]
    elif channels != 'all':
        pixels = pixels[..., channels]
    else:
        pixels = pixels
    # compute the glyph
    negative_weights = -pixels
    scale = np.maximum(pixels.max(), negative_weights.max())
    pos = _create_feature_glyph(pixels, vectors_block_size)
    pos = pos * 255 / scale
    glyph_image = pos
    if use_negative and pixels.min() < 0:
        neg = _create_feature_glyph(negative_weights, vectors_block_size)
        neg = neg * 255 / scale
        glyph_image = np.concatenate((pos, neg))
    # return as c-contiguous
    return np.ascontiguousarray(glyph_image[..., None])
r"""
    Create glyph of a feature image. If `pixels` have negative values, the
    `use_negative` flag controls whether there will be created a glyph of
    both positive and negative values concatenated the one on top of the
    other.

    Parameters
    ----------
    pixels : `ndarray`
        The input image's pixels.

    vectors_block_size: int
        Defines the size of each block with vectors of the glyph image.

    use_negative: bool
        Defines whether to take into account possible negative values of
        feature_data.
    
r"""
Create glyph of a feature image. If `pixels` have negative values, the
`use_negative` flag controls whether there will be created a glyph of
both positive and negative values concatenated the one on top of the
other.

Parameters

pixels : `ndarray`
The input image's pixels.

int
Defines the size of each block with vectors of the glyph image.

bool
Defines whether to take into account possible negative values of
feature_data.
r " " " Create glyph of a feature image . If ` pixels ` have negative values the ` use_negative ` flag controls whether there will be created a glyph of both positive and negative values concatenated the one on top of the other . Parameters pixels : ` ndarray ` The input image ' s pixels . int Defines the size of each block with vectors of the glyph image . bool Defines whether to take into account possible negative values of feature_data .
def glyph(pixels, vectors_block_size=10, use_negative=False, channels=None):
    if channels is None:
        pixels = pixels[..., :4]
    elif channels != 'all':
        pixels = pixels[..., channels]
    else:
        pixels = pixels
    negative_weights = -pixels
    scale = np.maximum(pixels.max(), negative_weights.max())
    pos = _create_feature_glyph(pixels, vectors_block_size)
    pos = pos * 255 / scale
    glyph_image = pos
    if use_negative and pixels.min() < 0:
        neg = _create_feature_glyph(negative_weights, vectors_block_size)
        neg = neg * 255 / scale
        glyph_image = np.concatenate((pos, neg))
    return np.ascontiguousarray(glyph_image[..., None])
def glyph ( pixels , vectors_block_size = 10 , use_negative = False , channels = None ) : if channels is None : pixels = pixels [ ... , : 4 ] elif channels != 'all' : pixels = pixels [ ... , channels ] else : pixels = pixels negative_weights = - pixels scale = np . maximum ( pixels . max ( ) , negative_weights . max ( ) ) pos = _create_feature_glyph ( pixels , vectors_block_size ) pos = pos * 255 / scale glyph_image = pos if use_negative and pixels . min ( ) < 0 : neg = _create_feature_glyph ( negative_weights , vectors_block_size ) neg = neg * 255 / scale glyph_image = np . concatenate ( ( pos , neg ) ) return np . ascontiguousarray ( glyph_image [ ... , None ] )
r"""
Create glyph of a feature image.
r " " " Create glyph of a feature image .
r"""
    Create glyph of a feature image. If `pixels` have negative values, the
    `use_negative` flag controls whether there will be created a glyph of
    both positive and negative values concatenated the one on top of the
    other.

    Parameters
    ----------
    pixels : `ndarray`
        The input image's pixels.

    vectors_block_size: int
        Defines the size of each block with vectors of the glyph image.

    use_negative: bool
        Defines whether to take into account possible negative values of
        feature_data.
    """ # first, choose the appropriate channels # compute the glyph # return as c-contiguous
pixels
vectors_block_size
use_negative
channels