Use following steps:
- Import all necessary modules:
import cv2import numpy as np
- Load an image and print its shape and type:
image = cv2.imread('../data/Lena.png').astype(np.float32) / 255print('Shape:', image.shape)print('Data type:', image.dtype)
- Convert the image to grayscale:
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)print('Converted to grayscale')print('Shape:', gray.shape)print('Data type:', gray.dtype)cv2.imshow('gray', gray)cv2.waitKey()cv2.destroyAllWindows()
- Convert the image to HSV color space:
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)print('Converted to HSV')print('Shape:', hsv.shape)print('Data type:', hsv.dtype)cv2.imshow('hsv', hsv)cv2.waitKey()cv2.destroyAllWindows()
- Increase the brightness of ...