Extracting The Image RGB Values of a Pixel in Python Using OpenCV¶
In [2]:
import cv2
img = cv2.imread('machinelearning.png',1)
cv2.imshow('Machine Learning',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Get RGB Value of a Single Pixel¶
In [3]:
img[100,100]
Out[3]:
In [4]:
B,G,R = img[100,100]
print(B,G,R)
In [5]:
print('Type of the image : ' , type(img))
print()
print('Shape of the image : {}'.format(img.shape))
print('Image Hight {}'.format(img.shape[0]))
print('Image Width {}'.format(img.shape[1]))
print('Dimension of Image {}'.format(img.ndim))