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?
Asked
Active
Viewed 104 times
1 Answers
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
-
1I think it's overkill to import `numpy` just to use the `arange()` function, considering we're using integer and therefore the build-tin `range()` function is equivalent. – Marcello Romani Feb 24 '21 at 10:21
-