Example #1
0
def search_fractals(height,
                    width,
                    quality,
                    out_dir='/Volumes/internal/Datasets/flames',
                    num=1000):

    max_iter = width * height * quality

    for i in range(num):
        n = randint(4, 10)

        pixels = np.zeros((height, width, 4), dtype=np.uint8)
        counts = np.zeros((height, width), dtype=np.uint32)

        colors = generate_palette(n)
        maps = generate_transformations(n)

        write_parameters(os.path.join(out_dir, '{0}.txt'.format(i)), colors,
                         maps)

        pixels = render_fractal(pixels, counts, maps, colors, height, width,
                                max_iter)
        pixels = composite_black_background(pixels)

        writer = png.Writer(width=width, height=height, alpha=True)
        writer.write(open(os.path.join(out_dir, '{0}.png'.format(i)), 'w'),
                     pixels.reshape(-1, width * 4))
Example #2
0
def generate_fractal(number, height=3000, width=3000, quality=30, out_dir='/Volumes/internal/Datasets/flames'):

    parameters = read_parameters(os.path.join(out_dir, '{0}.txt'.format(number)))
    colors = parameters['colors']
    maps = parameters['maps']

    max_iter = width * height * quality

    pixels = np.zeros((height, width, 4), dtype=np.uint8)
    counts = np.zeros((height, width), dtype=np.uint32)

    pixels = render_fractal(pixels, counts, maps, colors, height, width, max_iter)
    pixels = composite_black_background(pixels)

    writer = png.Writer(width=width, height=height, alpha=True)
    writer.write(open('{0}_high_quality.png'.format(number), 'w'), pixels.reshape(-1, width * 4))
Example #3
0
def search_fractals(height, width, quality, out_dir='/Volumes/internal/Datasets/flames', num=1000):

    max_iter = width * height * quality

    for i in range(num):
        n = randint(4, 10)

        pixels = np.zeros((height, width, 4), dtype=np.uint8)
        counts = np.zeros((height, width), dtype=np.uint32)

        colors = generate_palette(n)
        maps = generate_transformations(n)

        write_parameters(os.path.join(out_dir, '{0}.txt'.format(i)), colors, maps)

        pixels = render_fractal(pixels, counts, maps, colors, height, width, max_iter)
        pixels = composite_black_background(pixels)

        writer = png.Writer(width=width, height=height, alpha=True)
        writer.write(open(os.path.join(out_dir, '{0}.png'.format(i)), 'w'), pixels.reshape(-1, width * 4))
Example #4
0
def generate_fractal(number,
                     height=3000,
                     width=3000,
                     quality=30,
                     out_dir='/Volumes/internal/Datasets/flames'):

    parameters = read_parameters(
        os.path.join(out_dir, '{0}.txt'.format(number)))
    colors = parameters['colors']
    maps = parameters['maps']

    max_iter = width * height * quality

    pixels = np.zeros((height, width, 4), dtype=np.uint8)
    counts = np.zeros((height, width), dtype=np.uint32)

    pixels = render_fractal(pixels, counts, maps, colors, height, width,
                            max_iter)
    pixels = composite_black_background(pixels)

    writer = png.Writer(width=width, height=height, alpha=True)
    writer.write(open('{0}_high_quality.png'.format(number), 'w'),
                 pixels.reshape(-1, width * 4))