dimanche 23 décembre 2018

How to select a continuous sample at random from a list?

I have input arrays of varying depths, ranging from 20 till 32. I cannot pad them to make them all the same size, so the best option is to randomly select the z-depth of an image at every iteration.

I've read that numpy.random.choice() can be used for this but I get a random arrangement of indices, I want a continuous selection.

z_values = np.arange(img.shape[0]) # get the depth of this sample
z_rand = np.random.choice(z_values, 20) # create an index array for croping

The above gives me:

[22  4 31 19  9 24 13  6 20 17 28  8 11 27 14 15 30 16 12 25]

Which is not useful for me as they are not continuous and I cannot use it to crop my volume.

Is there any way to get a continuous random sample?

Thanks




Aucun commentaire:

Enregistrer un commentaire