0

I was referring the open-cv dense optical-flow code and and I found the following :

hsv[...,1] = 255

What is the meaning of this?

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

harinsamaranayake
  • 751
  • 2
  • 12
  • 32

1 Answers1

0

For the array hsv all values in the first column are set to 255. I believe open-cv took the syntax from 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]]])
Kenan
  • 13,156
  • 8
  • 43
  • 50
  • If we take this: hsv = np.random.randint(0, 10, (3,5,4)) output looks like this : [[[ 4 255 8 9] [ 9 255 9 0] [ 0 255 0 5] [ 1 255 1 9] [ 1 255 4 6]] [[ 8 255 4 1] [ 0 255 1 3] [ 3 255 8 8] [ 6 255 8 3] [ 4 255 3 4]] [[ 7 255 1 4] [ 8 255 1 5] [ 3 255 3 0] [ 2 255 8 2] [ 4 255 4 6]]] can we genaralize it? As the colum value of the internal array? – harinsamaranayake Dec 27 '19 at 05:21
  • updated to be more general – Kenan Dec 27 '19 at 05:44