O'Reilly logo

NumPy Cookbook - Second Edition by Ivan Idris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Combining images

In this recipe, we will combine the famous Mandelbrot fractal (see http://en.wikipedia.org/wiki/Mandelbrot_set) and the image of Lena. The Mandelbrot set was invented by the mathematician Benoit Mandelbrot. These types of fractals are defined by a recursive formula, where you calculate the next complex number in a series by multiplying the current complex number you have by itself and adding a constant to it. More details will be covered in this recipe.

Getting ready

Install SciPy if necessary. The See also section has a reference to the related recipe.

How to do it...

Start by initializing the arrays, followed by generating and plotting the fractal, and finally combining the fractal with the Lena image:

  1. Initialize the x, y, and

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required