Reputation: 124
I am trying to create an iteration over an image grid with x and y coordinations using Python. This image operation also involves applying an effect represented with parameter "c".
I'm struggling to make this work as intended which is as iteration navigates the grids via steps of 500 px c should also increase by 0.1. But after each row c will reset in my code.
There must be smarter ways to do this but I couldn't figure it out. Can someone contribute? Thanks in advance.
Edit: c was already incrementing correctly in my code and this wasn't the issue. in fact the way the effect works c needed to be reset and accepted answer worked well for that, thank you to all contributors.
c=0
for x in range(0,5000,500):
for y in range(0,5000,500):
new_img = brightness_filter.enhance(c)
img.paste(new_img, (x, y))
c+=0.1
new.show()
Upvotes: 0
Views: 29
Reputation: 99
If I'm understanding you correctly, this should be what you are looking for?
for x in range(0,5000,500):
c=0
for y in range(0,5000,500):
new_img = brightness_filter.enhance(c)
img.paste(new_img, (x, y))
c+=0.1
new.show()
though it'd be easier to define c as a function of y, so something like this:
for x in range(0,5000,500):
for y in range(0,5000,500):
c = y / 5000
new_img = brightness_filter.enhance(c)
img.paste(new_img, (x, y))
new.show()
Upvotes: 2