(filenames, options)
return input_filenames, global_palette
Fetch the global palette for a series of input files by merging
their samples together into one large array.
Fetch the global palette for a series of input files by merging
their samples together into one large array.
Fetch the global palette for a series of input files by merging their samples together into one large array .
def get_global_palette(filenames, options):
    '''Fetch the global palette for a series of input files by merging
their samples together into one large array.

    '''

    input_filenames = []

    all_samples = []

    if not options.quiet:
        logger.info('building global palette...')

    for input_filename in filenames:

        img, _ = load(input_filename)
        if img is None:
            continue

        if not options.quiet:
            logger.info('  processing {}...'.format(input_filename))

        samples = sample_pixels(img, options)
        input_filenames.append(input_filename)
        all_samples.append(samples)

    num_inputs = len(input_filenames)

    all_samples = [s[:int(round(float(s.shape[0]) / num_inputs))]
                   for s in all_samples]

    all_samples = np.vstack(tuple(all_samples))

    global_palette = get_palette(all_samples, options)

    if not options.quiet:
        logger.info('  done\n')

    return input_filenames, global_palette
def get_global_palette ( filenames , options ) : input_filenames = [ ] all_samples = [ ] if not options . quiet : logger . info ( 'building global palette...' ) for input_filename in filenames : img , _ = load ( input_filename ) if img is None : continue if not options . quiet : logger . info ( '  processing {}...' . format ( input_filename ) ) samples = sample_pixels ( img , options ) input_filenames . append ( input_filename ) all_samples . append ( samples ) num_inputs = len ( input_filenames ) all_samples = [ s [ : int ( round ( float ( s . shape [ 0 ] ) / num_inputs ) ) ] for s in all_samples ] all_samples = np . vstack ( tuple ( all_samples ) ) global_palette = get_palette ( all_samples , options ) if not options . quiet : logger . info ( '  done\n' ) return input_filenames , global_palette