I have a list of lists of integers. Such as
RedValues=[R,R1,R2,R3,R4]
R through R4 are all lists of integers.
What I need to do is compare the first value in each sublist and "take" the median value.
Specifically I am rebuilding an image with 9 different images and taking the median red color pixel in each file.
If anyone can be of assistance with this particular problem I appreciate it.
So R[3]
compared to R1[3]
compared to R2[3]
...and take median.
Thinking about a nested for loop?... for x in RedValues: for x in R: ...?
You can loop over all the 0th elements, then the 1st, then the 2nd... using zip
:
for rs in zip(*RedValues):
m = median(list(rs))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.