Open In App

Create a white image using NumPy in Python

Last Updated : 15 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Let us see how to create a white image using NumPy and cv2. A white image has all its pixels as 255.


Method 1: Using np.full() method : 
 

Python3
# importing the libraries
import cv2
import numpy as np

# creating an array using np.full 
# 255 is code for white color
array_created = np.full((500, 500, 3),
                        255, dtype = np.uint8)

# displaying the image
cv2.imshow("image", array_created)

Output:


Method 2: By creating an array using np.zeroes()
 

Python3
# importing the modules
import numpy as np
import cv2

# creating array using np.zeroes()
array = np.zeros([500, 500, 3],
                 dtype = np.uint8)

# setting RGB color values as 255,255,255
array[:, :] = [255, 255, 255] 

# displaying the image
cv2.imshow("image", array)

Output:


 


Article Tags :
Practice Tags :

Similar Reads

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy