1

every one. i want to split an array using numpy. Though i know the syntax but dimensions and axis always confuses me. So if you can give some tips and explanation, i will be thankful to you. Let say there is a video with shape (128,224,224,3). 128 is the number of frames in the video. Now i want to split this video into multiple videos such that each videos has 32 frames. I do this following

video.reshape(len(video)//32,-1,3,224,224)

so the new shape is (4,32,224,224,3). Which mean that the whole video is spli into 4 parts. The first part has first 32 frame, second part has 32 to 64 frames, third part has 64 to 96 frames as so on. But i am confused about the order of frames. Some time i think the syntax should be

video.reshape(32,-1,3,224,224)

which result in same of (32,4,3,224,224) But i am not sure which one is correct. Looking for some intuitive answer, though i think first ones correct, but it confuses me always.

Mustafa Aydın
  • 17,645
  • 4
  • 15
  • 38
Talha Anwar
  • 2,699
  • 4
  • 23
  • 62
  • `video.reshape(-1,32,224,224,3)`. This will create an array of *4 videos*, each with *32 frames*, *224x224 pixels* with *3 RGB values* – Larry the Llama Jan 05 '22 at 11:06
  • video.reshape(len(video)//32,-1,3,224,224) --> you are dividing video into 4 continuous (32,3,224,224) arrays. video.reshape(4,3,224,224) --> you are dividing video into 32 continuous (4,3,224,224) arrays. you need to understand the concept of strides. Refer https://stackoverflow.com/questions/53097952/how-to-understand-numpy-strides-for-layman question for better understanding. Numpy arrays are by default stored in contiguous 1D C arrays( refer https://stackoverflow.com/questions/26998223/what-is-the-difference-between-contiguous-and-non-contiguous-arrays). –  Jan 05 '22 at 17:40

0 Answers0