Problem running FloodFill algorithm with PIL

Viewed 18

I'm trying to fill an image with a floodfill algorithm but it cant find python command

from queue import Queue
import queue
from PIL import Image

image = Image.open("/Users/mv/Desktop/Imagen.png")
image = image.convert("RGB")
r = (255, 0, 0)
x, y = 100, 100

def floodfill(grid, i, j, new_color):
w = image.width
h = image.height
old_color = image.getpixel((x, y))

queue = Queue()
queue.put((x, y))

while not queue.empty():
    x, y = queue.get()
    if x < 0 or x >= w or y < 0 or y >= h or image.getpixel((x, y)) != old_color:
        continue
    else:
        image.putpixel((x, y), new_color)
        queue.put((x+1,y))
        queue.put((x-1,y))
        queue.put((x,y+1))
        queue.put((x,y-1))

floodfill(image, x, y, r) image.save("ImageResult.png")

This is the error:

[Running] python -u "/Users/mv/Desktop/BFS-1"
/bin/sh: python: command not found

[Done] exited with code=127 in 0.007 seconds
0 Answers
Related