我有一张这样的图片:
我同时拥有蒙版和原始图像。我只想计算鸭子区域的色温。
现在,我正在遍历下面图像的每一行和每一列,并获得其值不为零的像素。但是我认为这不是正确的方法。有什么建议吗?
我所做的是:
xyzImg = cv2.cvtColor(resImage, cv2.COLOR_BGR2XYZ)
x,y,z = cv2.split(xyzImg)
xList=[]
yList=[]
zList=[]
rows=x.shape[0]
cols=x.shape[1]
for i in range(rows):
for j in range(cols):
if (x[i][j]!=0) and (y[i][j]!=0) and (z[i][j]!=0):
xList.append(x[i][j])
yList.append(y[i][j])
zList.append(z[i][j])
xAvg = np.mean(xList)
yAvg = np.mean(yList)
zAvg = np.mean(zList)
xs = xAvg / (xAvg + yAvg + zAvg)
ys = yAvg / (xAvg + yAvg + zAvg)
xyChrome = np.array([xs,ys])
但这太慢了,我不认为这是正确的...
答案 0 :(得分:2)