I'm new to coding and I'm really confused. From the code below, I'm trying to print out every single colour in the RGB spectrum from (0,0,0) to (255,255,255) so technically there should be 256^3 images printed with all the colours. I've kind of done it below which only does it for the red or blue or green spectrum and not the combinations. What I'm trying to do with all the colours that are printed out is to stitch them all together pixel by pixel in this format. I don't want to print out all the images but get the combined version at the end. Any help would be greatly appreciated! Thank you so much for the help!
I would like to get all the combinations of the 3 variables from 0 to 255. For example, the output from print axis
would be:
(0,0,0)
(1,0,0)
(2,0,0)
...
(255,0,0)
(0,1,0)
(0,2,0)
...
(0,255,0)
(0,0,1)
(0,0,2)
...
(0,0,255)
(1,0,1)
...
so basically all the different combinations of the 3 numbers until 255.
I tried using the one below but what I'm trying to do is a bit different where each pixel I want is different and stitched together in a pixel by pixel format by looping through the values.
from PIL import Image
import sys
im = Image.new("RGB", (1, 1))
pix = im.load()
red=0
green=0
blue=0
j=0
while red<255 and green<255 and blue<255:
j+=1
red +=1
#green +=1
#blue+=1
for x in range(1):
for y in range(1):
axis = (red,green,blue)
pix[x,y] = axis
print axis
im.save('Test {}.png'.format(j), "PNG")
#stitching images together
images = map(Image.open, ['Test 1.png', 'Test 255.png', 'Test 100.png'])
widths, heights = zip(*(i.size for i in images))
total_width = sum(widths)
max_height = max(heights)
new_im = Image.new('RGB', (total_width, max_height))
x_offset = 0
for im in images:
new_im.paste(im, (x_offset,0))
x_offset += im.size[0]
new_im.save('test.jpg')