from matplotlib import pyplot as plt # import matplotlib import numpy as np # import numpy img = cv2.imread('C://Users//Admin2//Desktop//TechnoCSLAB.png') #Load the image file into memory plt.imshow(img) plt.title('Techno') plt.axis('off') plt.show()
#Program to display image from BGR to RGB
img = cv2.imread('C://Users//Admin2//Desktop//TechnoCSLAB.png') #Load the image file into memory plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) plt.title('man') plt.axis('off') #plt.show()
#Program to display image in Grayscale
img = cv2.imread('C://Users//Admin2//Desktop//TechnoCSLAB.png',0) # the number zero opens the image as a grayscale image plt.imshow(img, cmap = 'gray', interpolation = 'bicubic') #cmap specifies color mapping, gray in this case. plt.title('man') plt.axis('off') plt.show()
#Program to display region of interest from image
roi = img[1500:2500,1000:2000] #img[range of y, range of x] plt.imshow(cv2.cvtColor(roi, cv2.COLOR_BGR2RGB)) plt.title('man') plt.axis('off') plt.show()