Negative coordinate? #9372
Answered
by
radarhere
swalter972
asked this question in
Q&A
|
Hello, I use Pillow with my pupils in computer science class. It's a good exercise for visualizing matrices and coordinates. This is the first time I've encountered the problem of negative coordinates. For example, this code correctly returns an image with horizontal symmetry. from PIL import Image
image=Image.open("image-test.png")
L,H =image.size
#L'image a une résolution de L en largeur et H en hauteur
image_sym = Image.new("RGB",(L,H)) # création de l’image destination
#en RGB (rouge, vert, bleu)
# Inversion de l'image
for y in range(H): #
for x in range(L):#
p = image.getpixel((x,y)) #
image_sym.putpixel((x,-y),p) #
image_sym.show()I'm trying to understand why with the source code on github, but I don't have much time to look at everything, and the documentation on the coordinate system is rather brief. One might think of Python slices ([-1]), but these are tuples. thanks |
Answered by
radarhere
Jan 6, 2026
Replies: 2 comments 1 reply
|
Thanks, any reason for that ? (because my pupils shouted "IT works" despite of those negative coordinate) |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A user proposed the change in #3406 'so we can get the last pixels easily'.
It was released as part of Pillow 5.4.0 - https://pillow.readthedocs.io/en/stable/releasenotes/5.4.0.html#negative-indexes-in-pixel-access