![]() |
Pillow alternative? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Pillow alternative? (/thread-40427.html) |
Pillow alternative? - kucingkembar - Jul-26-2023 hi, sorry for my bad English, I tried to remove some lines of a webtoon picture if the line only contain 1 color (it is just an example, I cannot share real images because it have "rights") [attachment=2472] from PIL import Image Image.MAX_IMAGE_PIXELS = None img = Image.open('01.png') width = img.size[0] height = img.size[1] print("height : ",height,"\nwidth: ",width) for h in range(0,height): for w in range(0,width): pix = img.getpixel((h,w)) print("y : ",h,", x : ",w,", RGB Value : ",pix) print(h,w) break #limit to easy debugbut when I use my code in real webtoon images (not image above), the result is wrong: a line that I tested using the "pipet or color picker" tool using different software claims it is white or 255,255,255, but when I use that code some result is is my code, method, or something i don't know?or is there alternative package that i can use? Edit : i use combine 1 chapter into 1 file, so the file is large height : 130312 width: 720 Size : 44,9 MB (47.100.824 bytes) RE: Pillow alternative? - DPaul - Jul-26-2023 Hi, I would also use PIL for pixel peeping. So without having tested it,my suggestion would be to make sure that you are scanning the pixels in the right order. You start with 0,0 0,1 ... etc and you name this height, width. You are reading left-right, row by row. Have you verified that this is the right order? Paul RE: Pillow alternative? - deanhystad - Jul-26-2023 From Pillow documentation: https://pillow.readthedocs.io/en/stable/reference/Image.html Quote:Image.getpixel(xy) x is horizontal and y is vertical. Translating your code to use the correct coordinates. for h in range(0,height): for w in range(0,width): pix = img.getpixel((w, h)) print("y : ",h,", x : ",w,", RGB Value : ",pix) print(h,w) RE: Pillow alternative? - kucingkembar - Jul-27-2023 (Jul-26-2023, 05:39 PM)deanhystad Wrote: From Pillow documentation: https://pillow.readthedocs.io/en/stable/reference/Image.html thank you, thank you it was very stupid of me, I am so embarrassed i will give you reputation point RE: Pillow alternative? - Larz60+ - Jul-27-2023 The only stupid questions are the ones not asked! |