import cv2 img = cv2.imread("flower.jpg", cv2.IMREAD_GRAYSCALE) # Create a resizable window cv2.namedWindow("image", cv2.WINDOW_NORMAL) # Set the window size to a smaller size cv2.resizeWindow("image", 1600, 900) # Set the window size to 1600x900 # Display the image cv2.imshow("image", img) # cv2.waitKey(0) while True: key = cv2.waitKey(1) & 0xFF if key == 27: # Exit on 'ESC' key break if cv2.getWindowProperty("image", cv2.WND_PROP_VISIBLE) < 1: # Close on window close button break cv2.destroyAllWindows()