Page 341 - AI Ver 1.0 Class 10
P. 341

18.  Using the library: import cv2, matplotlib
                       Upload an image of your favourite food and display the picture in RGB color mode.
                  Ans.  Program:

                      import cv2
                      from matplotlib import pyplot as plt

                      import numpy as np
                      img = cv2.imread('D:\Pasta.jpg')
                      plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
                      plt.title('My Favourite Food')
                      plt.axis('off')

                      plt.show
                      Output:

                                           My Favourite Food






















                   19.  Using the library: import cv2, matplotlib
                       Upload an image of your favourite pet and display the picture in grayscale mode.
                  Ans.  Program:

                      import cv2
                      from matplotlib import pyplot as plt

                      import numpy as np
                      img = cv2.imread('D:\Dog.jpg',0)
                      plt.imshow(img, cmap = 'gray')
                      plt.title('My Pet')
                      plt.axis('off')

                      plt.show












                                                                                 Python Practical Questions  339
   336   337   338   339   340   341   342   343   344   345   346