I'm trying to extract a specific color from an image within a defined RGB range using the cv2 module. In the example below I am trying to isolate the fire from the exhaust of the space shuttle between yellow and white RGB values and then print out the percentage of RGB values within that range compared to the rest of the image.
Here is my minimal working example:
import cv2
import numpy as np
from matplotlib import pyplot as plt
import imageio
img = imageio.imread(r"shuttle.jpg")
plt.imshow(img)
This is the output image. Its from wikipedia.
img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
color1 = (255,255,0) #yellow
color2 = (255,25