vendredi 10 septembre 2021

Create subset index based on value of another variable - Python

On one side, I have a variable num which takes int values from 0, 1, 2, etc. up to 4 lets say.

On the other hand, I want to create a dstack using a variable imgs in which I have insert an index. imgs has a lengh of 40

num = [0,1,2,3,4] 

rgb = np.dstack((imgs[0], imgs[1], imgs[2]))  

So, what I am looking for is a trick in which when num=1, then the imgs[] index should be 0, 1 and 2. Then when num=1, the indices should be 10, 11, 12. When num=2, then 20, 21, 22 etc.

Any idea how to create this relationship?

Aucun commentaire:

Enregistrer un commentaire