import cv2 # Read the image in grayscale 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 # Resize the image to make it smaller img_resized = cv2.resize(img, (1500, 768)) # Resize to 800x600 or any desired size # Display the image cv2.imshow("image", img_resized) # cv2.waitKey(0) # Wait for a key press or close button 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 # Destroy all windows cv2.destroyAllWindows()