import cv2 # Load the image img = cv2.imread('flower.jpg') # 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 # User-defined constants a = 1.0 # Contrast control (1.0 keeps it unchanged) b = 70 # Brightness control (positive value to increase brightness) # Apply the brightness formula img_processed = cv2.convertScaleAbs(img, alpha=a, beta=b) # Save or display the result cv2.imwrite('flower_brightened.jpg', img_processed) # Display the image cv2.imshow("image", img_processed) # 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()