sierpinski_foam¶
- sierpinski_foam(shape, n: int = 5, mode: str = 'upper')[source]¶
Generates an image of a Sierpinski carpet or foam with independent control of image size and number of iterations
- Parameters:
shape (array_like) – The shape of the final image to create. To create a full image with no cropping, use a that is a multiple of 3**n.
n (int) – The number of times to iteratively divide the image. This functions starts by inserting single voxels, then inserts increasingly large squares/cubes.
mode (str) – Controls the portion of the image that is returned, options are ‘upper’ which returns the upper corner, ‘centered’, which returns the center portion of the image, and None provide the full image, in which case the returned image will be larger than shape.
- Returns:
im – A boolean image with False values inserted at the center of each square (or cubic) sub-section.
- Return type:
ndarray
Examples
Click here to view online example.