This is the behavior of matplotlib. It finds the minimum and maximum of your picture, makes those black and white, and scales everything in between.

This is useful for arbitrary data that may have integer or floating point types, and value ranges between 0.0 and 1.0, or 0 .. 255, or anything else.

You can set those limits yourself with vmin and vmax arguments:

plt.imshow(imgGray, cmap='gray', vmin=0, vmax=255) # if your data ranges is uint8

OpenCV does no such auto-scaling. It has fixed rules. If it's floating point, 0.0 is black and 1.0 is white. If it's uint8, the range is 0 .. 255.

To get such auto-ranging in OpenCV, you'll have to scale the data before displaying:

normalized = cv.normalize(
    data, alpha=0.0, beta=1.0, norm_type=cv.NORM_MINMAX, dtype=cv.CV_32F)
Answer from Christoph Rackwitz on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-grayscaling-of-images-using-opencv
Python | Grayscaling of Images using OpenCV - GeeksforGeeks
September 23, 2025 - Let's learn the different image processing methods to convert a colored image into a grayscale image. Python · import cv2 image = cv2.imread('C:\\Documents\\full_path\\tomatoes.jpg') gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.imshow('Grayscale', gray_image) cv2.waitKey(0) cv2.destroyAllWindows() Input: Input Image ·
🌐
GitHub
github.com › opencv › opencv-python › issues › 611
Problem displaying grayscale image overlaid on a blank canvas · Issue #611 · opencv/opencv-python
January 14, 2022 - This is an issue with imshow because cv2.imwrite() works as expected. ... img1 = np.random.randint(0, 255, (500, 500)).astype("uint8") # Random image img2 = np.ones((1500, 1500)) * 255 # Blank Canvas img2[: img1.shape[0], : img1.shape[1]] = img1 cv2.imshow("Output", img2) cv2.waitKey(0) cv2.destroyAllWindows() plt.imshow(img2, cmap="gray") plt.title("expected output") plt.show()
Author   chinge55
🌐
techtutorialsx
techtutorialsx.wordpress.com › 2018 › 06 › 02 › python-opencv-converting-an-image-to-gray-scale
Python OpenCV: Converting an image to gray scale – techtutorialsx
January 25, 2025 - import cv2 image = cv2.imread('C:/Users/N/Desktop/Test.jpg') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.imshow('Original image',image) cv2.imshow('Gray image', gray) cv2.waitKey(0) cv2.destroyAllWindows()
🌐
Jeremy Morgan
jeremymorgan.com › tutorials › opencv › how-to-grayscale-image
Grayscaling Images Made Simple with OpenCV
March 23, 2023 - Just for fun, let’s display the original and grayscale images side by side: cv2.imshow('Original Image', image) cv2.imshow('Grayscale Image', gray_image) Next we’ll wait for a key press (don’t close the window with the x key, it will lock up your terminal) to close the window.
🌐
OpenCV
forum.opencv.org › c++
Cv::imshow displays gray image -opencv 3.4 - C++ - OpenCV
October 13, 2022 - Hi, The following code displays a gray image even though img has the correct pixel values. what is missing in this code cv::Mat img = cv::imread("brain.jpg"); cv::imshow("img", img); cv::waitKey(0);
🌐
Medium
korlakuntasaikamal10.medium.com › the-difference-in-reading-an-image-using-opencv-and-matplotlib-5529415704e5
The difference in Reading an image using OpenCV and Matplotlib | by kamal_DS | Medium
January 25, 2023 - For Grayscale image, there will be no issues which mean if we read an image using OpenCV using imread and if we show an image using matplotlib imshow then the image will be the same. import cv2 import matplotlib.pyplot as plt image_gray = ...
🌐
TutorialsPoint
tutorialspoint.com › python-grayscaling-of-images-using-opencv
Python Grayscaling of Images using OpenCV
November 13, 2024 - import cv2 # Read the image image = cv2.imread('apple.jpg') # Convert the image to grayscale gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Display the grayscale image (optional) cv2.imshow('Grayscale Image', gray_image) cv2.waitKey(0) cv2.destroyAllWindows()
Find elsewhere
🌐
OpenCV Q&A Forum
answers.opencv.org › question › 22102 › windows-imshow-sometimes-showing-gray-image
Windows imshow sometimes showing gray image - OpenCV Q&A Forum
I found a solution by modifying ... res) cv2.waitKey(0) The problem is indeed that imshow() works badly with files other than CV_8U file and can result in wrong image (like all gray images) when given 32F file, which are produced by some functions like StereoBM or other ...
🌐
Piratefsh
piratefsh.github.io › image-processing-101
Image Processing 101
# create 100 x 100 pixel array with average color value average_color_img = np.array([[average_color]*100]*100, np.uint8) plt.imshow(average_color_img) ... # threshold for grayscale image _, threshold_img = cv2.threshold(gray_img, 60, 255, cv2.THRESH_BINARY) threshold_img = cv2.cvtColor(threshold_img, cv2.COLOR_GRAY2RGB) plt.figure(figsize=(10,10)) plt.imshow(threshold_img)
🌐
Studyopedia
studyopedia.com › home › set a grayscale filter with opencv
Set a Grayscale filter with OpenCV - Studyopedia
March 15, 2025 - # Read and display an image with OpenCV and give it a grayscale filter import cv2 # Load an image # The cv2.IMREAD_GRAYSCALE here gives grayscale to the image image = cv2.imread(r'C:\Users\hp\Downloads\Astronaut.png', cv2.IMREAD_GRAYSCALE) # Display the image cv2.imshow("Grayscale Filter", image) # Wait for a key press and close the window cv2.waitKey(0) cv2.destroyAllWindows()
🌐
DataFlair
data-flair.training › blogs › image-conversion-using-opencv
Image Conversion using OpenCV - Colored, Grayscale and Binary - DataFlair
March 4, 2024 - 2. Iterate through each pixel of the color image. 3. For each pixel, calculate the grayscale intensity using the weighted average of the RGB values. 4. Set the grayscale intensity value for that pixel in the grayscale image. 5. Display the grayscale image using cv2.imshow() function.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-opencv-cv2-cvtcolor-method
Python OpenCV | cv2.cvtColor() method - GeeksforGeeks
August 11, 2025 - import cv2 src = cv2.imread(r'... cv2.waitKey(0) cv2.destroyAllWindows() Output · Explanation: cv2.cvtColor(src, cv2.COLOR_BGR2GRAY): Converts image to grayscale....
🌐
Dev-akash
dev-akash.in › blogs › how-to-convert-color-image-to-grayscale-in-opencv
How to convert color image to grayscale in OpenCV
import cv2 # Reading color image as grayscale gray = cv2.imread("color-img.png",0) # Showing grayscale image cv2.imshow("Grayscale Image", gray) # waiting for key event cv2.waitKey(0) # destroying all windows cv2.destroyAllWindows() cvtColor() function in OpenCV is very helpful in converting color channels from one to another such as BRG to HSV or BRG to RGB.
🌐
TutorialsPoint
tutorialspoint.com › show-a-grayscale-open-cv-image-with-matplotlib
Show a grayscale Open CV image with Matplotlib
June 1, 2021 - import cv2 # Read the image image = cv2.imread('apple.jpg') # Convert the image to grayscale gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Display the grayscale image (optional) cv2.imshow('Grayscale Image', gray_image) cv2.waitKey(0) cv2.destroyAllWindows()
🌐
TutorialsPoint
tutorialspoint.com › converting-an-image-from-colour-to-grayscale-using-opencv
Converting an image from colour to grayscale using OpenCV
March 17, 2021 - Step 1: Import OpenCV. Step 2: Read the original image using imread(). Step 3: Convert to grayscale using cv2.cvtcolor() function. import cv2 image = cv2.imread('colourful.jpg') cv2.imshow('Original',image) grayscale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.imshow('Grayscale', grayscale)
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-opencv-cv2-imshow-method
Python OpenCV | cv2.imshow() method - GeeksforGeeks
Example 1: In this example, an ... cv2.imshow("Gray Image", img) cv2.waitKey(0) cv2.destroyAllWindows() Output: The grayscale image is displayed in a window....
Published   February 23, 2026