# Overlay an image segmentation with Numpy and Matplotlib

MatplotlibPythonData Visualization

To overlay an image segmentation with numpy, we can take the following Steps −

• Make a masked array of 10×10 dimension.

• Update the masked array with 1 for some region.

• Make image data using numpy.

• Mask an array where a condition is met, to get the masked data.

• Create a new figure or activate an existing figure using figure() mrthod.

• Use imshow() method to display data as an image, i.e., on a 2D regular raster.

• To display the figure, use show() method.

## Example

from matplotlib import pyplot as plt
import numpy as np
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
mask = np.zeros((10, 10))
mask[3:-3, 3:-3] = 1
im = mask + np.random.randn(10, 10) * 0.01
plt.show()