How to Use Different Color Codes in OpenCV

Free OpenCV course with real-time projects Start Now!!

Program 1

import cv2
import matplotlib.pyplot as plt
img=cv2.imread("D://opencvapp//wildlifeImages//wildlife-tiger.jpg")
cv2.imshow('Origal Image ',img)
#BGR to RGB
rgb=cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
cv2.imshow('RGB in OpenCV Image ',rgb)
plt.imshow(rgb)
plt.show()

# #BGR to Gray
# gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# cv2.imshow('Gray Image ',gray)
# #BGR to HSV
# hsv=cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
# cv2.imshow('HSV Image ',hsv)
# #BGR to LAB
# lab=cv2.cvtColor(img,cv2.COLOR_BGR2LAB)
# cv2.imshow('LAB Image ',lab)
# cv2.waitKey(0)
# cv2.destroyAllWindows()

 

Did you like this article? If Yes, please give DataFlair 5 Stars on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *