Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # importing(bringing-in) the essential libraries
- # An Open-source library for Computer Vision and image processings, hence the name openCV.
- import cv2
- # To show the image/graphs etc.
- import matplotlib.pyplot as plt
- # Numpy helps us perform matrix (rows and columns of number) operation on images. Since, images are rows and columns of numbers.
- import numpy as np
- #The output of plotting commands is displayed inline within frontends like the Jupyter notebook.
- #%matplotlib inline #uncomment %matplotlib inline while using jupyter.
- # Reading in an image
- img = cv2.imread('images.jpg')
- # Always make a copy while operating on your image, so that your original image doesn't get affected.
- img1 = np.copy(img)
- #openCV reads/brings the image in BGR format (blue channel first, then green and finally red).
- #If you plot/show your image using plt.imshow('img1'), it will appear weired.
- # Finally plot/show the image
- plt.title('weired looking image in BGR format')
- plt.imshow(img1)
- # Reading in an image
- img = cv2.imread('images.jpg')
- # Always make a copy while operating on your image, so that your original image doesn't get affected.
- img1 = np.copy(img)
- #openCV reads/brings the image in BGR format (blue channel first, then green and finally red).
- #If you plot/show your image using plt.imshow('img1'), it will appear weired.
- # Finally plot/show the image
- plt.title('weired looking image in BGR format')
- plt.imshow(img1)
- #So you need to bring it to RGB format.By using cv2.cvtColor(img,cv2.COLOR_BGR2RGB).
- img_bgr =np.copy(img)
- img_rgb=cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
- plt.title('origional image in RGB format')
- plt.imshow(img_rgb)
Add Comment
Please, Sign In to add comment