-1

I have a list of 21 grayscale images. I want to determine and save all the possible 3 layer combinations out of these 21 images. Can anyone a suggest a way in python?

Sam
  • 59
  • 11

1 Answers1

0

If you have 21 grayscale images, you could read them all and you would get 21 indices from 0 20.

The code to choose the indices combinations could look like:

import itertools

listOfIndices = list(range(20))
combinations = list(set(list(itertools.combinations(listOfIndices,3))))

This works for any combination without repetitions. If you are ok with the repetitions, the last line becomes:

combinations = list(itertools.combinations(listOfIndices,3))

where each of the element is a 3-index tuple.

tino
  • 160
  • 6