Skip to content
Advertisement

Tag: pixel

How to iterate through neighbours in 2D coordinates?

In a 2D plane, I want to check the neighbouring points until meeting a condition. For example, take a red pixel in this image (x,y). I want to iterate to find the white pixel closest to the selected red pixel. This is an updated image provided by @Pranav Hosangadi My original code is now irrelevant. A possible solution is to

How to read the RGB value of a given pixel in Python?

If I open an image with open(“image.jpg”), how can I get the RGB values of a pixel assuming I have the coordinates of the pixel? Then, how can I do the reverse of this? Starting with a blank graphic, ‘write’ a pixel with a certain RGB value? I would prefer if I didn’t have to download any additional libraries. Answer

Advertisement