How to Create a Blank Image in Python using Numpy



Python


In this article, we show how to create a blank image in Python using the numpy module.

Creating a blank image is important, because for many different types of tasks you need to do, such as drawing shapes with OpenCV requires that there be an image in place to draw the shapes.

With OpenCV, you can do things such as draw shapes on any type of image, but usually this is done on a blank image.

A blank image is an image that has nothing on it except a certain color. This can be an all-white image, an all-black image, an all-gray image, etc.

With modules such as numpy, we can create a completely blank image.

Below we show how to make blank images in a variety of different colors.

So the code to do this is shown below.



Using this code, we get a variety of blank images, which act as a canvass in which we can now add different things to, such as draw shapes.

And this is how to create a blank image in Python using the numpy module.


Related Resources

How to Randomly Select From or Shuffle a List in Python



HTML Comment Box is loading comments...