Esempio n. 1
0
to_space = [lab, srgb, cam, camucs]
space_back = [lab_back, srgb_back, cam_back, camucs_back]
name = ['lab', 'srgb', 'cam', 'camucs']

for current_iteration in range(N):
    print('CURRENT_ITERATION:', current_iteration)
    np.random.seed(SEED + current_iteration)

    start_rgb = color.hex_2_rgb(START_COLOR)
    end_rgb = color.hex_2_rgb(END_COLOR)

    start_conv = to_space[current_iteration](start_rgb)
    end_conv = to_space[current_iteration](end_rgb)

    num_steps = 50
    interp_j = np.linspace(start_conv[0], end_conv[0], num_steps)
    interp_c = np.linspace(start_conv[1], end_conv[1], num_steps)
    interp_h = np.linspace(start_conv[2], end_conv[2], num_steps)

    gradient = np.stack((interp_j, interp_c, interp_h),
                        axis=1).reshape(1, num_steps, 3)
    gradient = space_back[current_iteration](gradient)
    gradient = np.clip(gradient, 0, 255)
    img = data.upscale_nearest(gradient, ny=1000, nx=20).astype('uint8')
    print(img.shape)

    file.export_image(name[current_iteration] + '%d_%d' %
                      (current_iteration, int(round(time.time() * 1000))),
                      img,
                      format='png')
Esempio n. 2
0
        p1, p2 = PS[current_iteration]
        print(p1, p2)

        image[:, :WIDTH // 2] = r.binomial_from(rkey,
                                                1,
                                                p1,
                                                size=(HEIGHT, WIDTH // 2))
        image[:, WIDTH // 2:] = r.binomial_from(rkey,
                                                1,
                                                p2,
                                                size=(HEIGHT, WIDTH // 2))

        return data.upscale_nearest(data.prepare_image_for_export(image * 255),
                                    ny=UPSCALE_FACTOR_Y,
                                    nx=UPSCALE_FACTOR_X)

    if START_SERVER is True:
        viz.start_image_server(generate_full_image, COLOR_STRING,
                               SEED + current_iteration)
        break
    elif SAVE_IMAGES is True:
        image = generate_full_image(COLOR_STRING, SEED + current_iteration)
        file.export_image('%d_%d_%d' %
                          (current_iteration, SEED + current_iteration,
                           int(round(time.time() * 1000))),
                          image,
                          format='png')
    else:
        generate_full_image(COLOR_STRING, SEED + current_iteration)
Esempio n. 3
0
                           num_tiles=TILING_OPTIONS)

        basic_tiles += [pats]

    basic_tiles = m.SimpleProgression(values=basic_tiles, child_lengths=1)

    r = [m.SimpleProgression(values=i) for i in [2, 3, 10, 11, 12]]
    random_tiles = m.Processor(m.SimpleProgression(
        values=m.RandomMarkovModel(values=r, child_lengths=[1, 2, 3, 4]),
        child_lengths=TILE_HEIGHT * TILE_WIDTH // 2),
                               num_tiles=1,
                               length_limit=TILE_HEIGHT * TILE_WIDTH)

    parent = m.RandomMarkovModel(values=[basic_tiles, random_tiles],
                                 child_lengths=1)

    img = gen_channel(parent)[:, :, 0]
    print(img.shape)
    print(np.min(img))
    print(np.max(img))
    colored_image = color.replace_indices_with_colors(img, COLOR_DICT)
    print(colored_image.shape)

    if N == 1:
        viz.show_image(colored_image)
    else:

        file.export_image('%d_%d' %
                          (current_iteration, int(round(time.time() * 1000))),
                          colored_image.astype('uint8'),
                          format='png')