0

What is an easy way getting this array of size (112, 112, 6) into (112, 112, 3). Could np.squeeze(image) be used?

Below is the numpy.array with it's current shape.

(112, 112, 6)

[[[  0.     0.     0.   683.25 237.5  472.  ]
  [  0.     0.     0.   684.25 230.25 465.  ]
  [  0.     0.     0.   690.   222.25 459.  ]
  ...
  [  0.     0.     0.   146.    56.   209.  ]
  [  0.     0.     0.   155.25  69.25 217.5 ]
  [  0.     0.     0.   156.25  69.75 215.5 ]]

 [[  0.     0.     0.   676.5  227.   460.25]
  [  0.     0.     0.   677.25 219.25 453.75]
  [  0.     0.     0.   682.25 211.25 448.25]
  ...
  [  0.     0.     0.   131.    37.5  190.5 ]
  [  0.     0.     0.   138.75  45.75 194.5 ]
  [  0.     0.     0.   148.5   53.   200.25]]

 ...

 [[  0.     0.     0.   650.   362.25 548.25]
  [  0.     0.     0.   646.75 369.   556.5 ]
  [  0.     0.     0.   575.5  315.75 506.5 ]
  ...
  [  0.     0.     0.   755.   765.   763.  ]
  [  0.     0.     0.   759.25 761.75 765.  ]
  [  0.     0.     0.   765.   758.5  765.  ]]

 [[  0.     0.     0.   654.   362.75 552.75]
  [  0.     0.     0.   638.5  359.5  549.25]
  [  0.     0.     0.   544.   286.5  476.75]
  ...
  [  0.     0.     0.   752.25 765.   763.  ]
  [  0.     0.     0.   758.   761.25 765.  ]
  [  0.     0.     0.   764.75 757.5  765.  ]]]
iustin
  • 66
  • 10

1 Answers1

0

np.squeeze is used for reducing dimensions, not size of dimensions. That is, if you had a vector of shape (x, y, z, 1), np.squeeze would make it of the shape (x, y, z).

In your case, you need to slice the vector. Since you know that the first three values of the last dimension are zeros, you can easily slice them out:

output_vector = input_vector[:, :, 3:]
Susmit Agrawal
  • 3,649
  • 2
  • 13
  • 29