Check out example codes for "cvtcolor rgb to gray". It will help you in understanding the concepts better.

Code Example 1

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

Code Example 2

img_gray_mode = cv2.imread(path, cv2.IMREAD_GRAYSCALE)

Code Example 3

cv::Mat img
cv::cvtColor(img, img, CV_BGR2GRAY);

Learn ReactJs, React Native from akashmittal.com