I'm trying to find the color invariants of a photo. I searched it and found that I need to find the value of c1
as its simplest feature. We can find c1
by this formula c1=(r/max(g,b))
.
When I try to find img cols and rows with img.shape
and split this image b,g,r.
import cv2
import math
import matplotlib.pyplot as plt
img = cv2.imread('CU.png')
b,g,r = cv2.split(img)
cv2.imshow('Image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
print(img.shape)
rows,cols,channels = img.shape
for i in range(rows):
for j in range(cols):
b = img[i,j,0]
g = img[i,j,1]
r = img[i,j,2]
x = (r/max(g,b))
c1= math.atan(x)
plt.plot(i,j,c1)
plt.show()
I thought I should split the picture into rows and columns and then break it down into b, g, r. I had to find c1 using the values b, g, r in each row and column, but I'll do this c1
later.
I wonder if anyone knows about it? How to find color constants or what should I do or is my method of finding this c1
correct?