Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
424 views
in Technique[技术] by (71.8m points)

Color Invariants usage with Python OpenCV

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...