mandelbrot.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:vizgen 作者: uva-graphics 项目源码 文件源码
def mandelbrot_color(matrix, output_file_name):
    """Generates a color version of the Mandelbrot Set

    Writes its output file to output_file_name

     Args:
        matrix: np.array, 2D array representing the mandelbrot set
        output_file_name: string, filename to write image to
    """

    # I wasn't quite sure on how to do the coloring, so I just interpolated
    # between two colors:
    color1 = np.array([[.2], [.2], [.8]])
    color2 = np.array([[1], [.2], [.5]])

    color_img = np.zeros((matrix.shape[0], matrix.shape[1], 3))

    color_img[:, :, 0] = color1[0] + matrix[:, :] * (color2[0] - color1[0])
    color_img[:, :, 1] = color1[1] + matrix[:, :] * (color2[1] - color1[1])
    color_img[:, :, 2] = color1[2] + matrix[:, :] * (color2[2] - color1[2])

    print("\nWriting image to:", output_file_name)
    skimage.io.imsave(output_file_name, color_img)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号