Brian Lo
Brian Lo

Reputation: 71

Need help to explain a line of Opencv/Numpy code

Can someone please explain to me what would the following line do?

bgr = img[:,:,:3]

Upvotes: 0

Views: 60

Answers (1)

Brandt
Brandt

Reputation: 5659

What you want to look for here is "slicing" and "indexing". Have a look on those links:

Basically, img is a 3-dimensional array and you are selecting all elements of axis "0" and "1", but only the first 3 elements ([0,1,2])of axes "2".

Upvotes: 4

Related Questions