I'm trying to get the NDVI of a plant image. This is my first time doing this so I'm not sure if the steps I've taken are correct. In the second block, I added a colormap to the NIR Image and then split the channels so I can use the NDVI formula for the NIR channel and the Red channel. In the last block I applied the formula and plotted the image. The resulting values in the second block kinda look off to me, but I'm not sure how check if this is correct.
import os
from PIL import Image
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
from IPython.display import display
import cv2
import cmapy
img_path = os.getcwd() + "/plant.png"
img = Image.open(img_path)
plt.figure(figsize = (10,10))
test_img = img
plt.imshow(test_img)
test_img2 = cv2.imread(img_path)
img_c = cv2.applyColorMap(test_img2, cmapy.cmap('Reds')).astype(np.int)
_, R, NIR = cv2.split(img_c)
plt.figure(figsize = (10,10))
plt.imshow(img_c)
plt.show()
ndvi = (NIR-R)/(NIR+R+0.01)
print(ndvi.max()) 0.9999029220464032
print(ndvi.mean()) 0.10046810466714343
print(ndvi.min()) 0.01999960000799984
plt.figure(figsize = (10,10))
plt.imshow(ndvi)
plt.show()


