hsv [...,1] = 255是什么意思?

时间:2019-12-27 05:02:46

标签: python opencv

我正在参考open-cv密集光流代码,发现以下内容:

hsv[...,1] = 255

这是什么意思?

代码:https://docs.opencv.org/3.4/d4/dee/tutorial_optical_flow.html

1 个答案:

答案 0 :(得分:0)

对于数组hsv,第一列中的所有值均设置为255。我相信open-cv采用了numpy的语法

hsv = np.random.randint(0, 10, (3,5))
>>> arr = np.random.randint(0, 10, (3,5, 4))
>>> arr
array([[[7, 7, 8, 3],
        [2, 7, 6, 6],
        [6, 8, 6, 6],
        [7, 5, 7, 6],
        [4, 1, 1, 7]],

       [[5, 4, 1, 0],
        [2, 2, 2, 0],
        [4, 4, 7, 4],
        [8, 5, 9, 3],
        [5, 6, 4, 7]],

       [[8, 6, 3, 3],
        [5, 4, 6, 4],
        [3, 4, 1, 9],
        [8, 0, 5, 4],
        [5, 0, 7, 6]]])
>>> arr[..., 1] = 255
>>> arr
array([[[  7, 255,   8,   3],
        [  2, 255,   6,   6],
        [  6, 255,   6,   6],
        [  7, 255,   7,   6],
        [  4, 255,   1,   7]],

       [[  5, 255,   1,   0],
        [  2, 255,   2,   0],
        [  4, 255,   7,   4],
        [  8, 255,   9,   3],
        [  5, 255,   4,   7]],

       [[  8, 255,   3,   3],
        [  5, 255,   6,   4],
        [  3, 255,   1,   9],
        [  8, 255,   5,   4],
        [  5, 255,   7,   6]]])