i = 0
for x in range(0, 5):
for y in range(0, 5):
if 0 == outputAfterLearning[i]:
image.putpixel((x, y), (0, 0, 0))
elif 1 == outputAfterLearning[i]:
image.putpixel((x, y), (255, 255, 255))
i += 1
for x in range(0, 5):
for y in range(5, 10):
if 0 == outputAfterLearning[i]:
image.putpixel((x, y), (0, 0, 0))
elif 1 == outputAfterLearning[i]:
image.putpixel((x, y), (255, 255, 255))
i += 1
for x in range(5, 10):
for y in range(0, 5):
if 0 == outputAfterLearning[i]:
image.putpixel((x, y), (0, 0, 0))
elif 1 == outputAfterLearning[i]:
image.putpixel((x, y), (255, 255, 255))
i += 1
for x in range(5, 10):
for y in range(5, 10):
if 0 == outputAfterLearning[i]:
image.putpixel((x, y), (0, 0, 0))
elif 1 == outputAfterLearning[i]:
image.putpixel((x, y), (255, 255, 255))
i += 1
As you can see, I am repeating the image using 5x5px squares and setting pixels in them.
The above code is obviosuly for an image with dimensions of 10x10px, but I would like to write the code in a more general way, so I can use it for large images (say 30x30px) without adding 32 new loops.