python - How to extract array from the first element of triples in 2d array of triples using numpy -


I have an array with size (480, 640, 3) and I have an array Using all the first elements that are made using triple. I tried

newArray = array [np.arange (array.shape [0]), np.arange (array.shape [1]), 0]

But he gives it:

can not be transmitted in a shape

I understand why, and if it works So it would not really be that I wanted anyway. I want to end with an array with size (480, 640) , and that command would give me the 1d array.

So, how do I get what I want? I'm browsing docs and tutorial numpy, but I do not know a lot of the vocabulary (I'm just starting to use this nowadays) that I do not understand what I should do.

Looks like you want to take a piece on the depth axis:

 < Code> in [8]: A = np.ones ((480,640,3)) [9]: a [:,:, 0] outside [9]: array ([[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., .. ., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]]) [10]: one [:,:, 0]. Shape out [10]: (480, 640)    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -