Page 343 - AI Ver 1.0 Class 10
P. 343
21. Using the library: import cv2, matplotlib
Upload an image of a banana tree and change the color of the tree in the image and save it in your drive.
Ans. Program:
import cv2
from matplotlib import pyplot as plt
import numpy as np
img = cv2.imread('D:\Banana Tree.jpg',0)
plt.imshow(img, cmap = ‘gray’)
plt.title('Banana Tree')
plt.axis('off')
plt.show
cv2.imwrite('E:\Banana tree after color change.jpg',img)
Output:
True
Banana Tree
Python Practical Questions 341

