# Importing the pillow library's # desired modules from PIL import Image, ImageDraw # Opening the image (R prefixed to # string in order to deal with '\' # in paths) img = Image.open(R"27.jpg") # Converting the image to RGB mode img = img.convert("RGB") #img.show() seed = (100, 100) rep_value = (132, 109, 106) ImageDraw.floodfill(img, seed, rep_value, thresh=85) seed = (218, 678) rep_value = (132, 109, 106) ImageDraw.floodfill(img, seed, rep_value, thresh=85) seed = (218, 678) rep_value = (132, 109, 106) ImageDraw.floodfill(img, seed, rep_value, thresh=85) seed = (597, 674) rep_value = (132, 109, 106) ImageDraw.floodfill(img, seed, rep_value, thresh=75) img.save("tonx.jpg") # Displaying the image img.show() #################################################################################################### to select pixel for flooding area: from tkinter import Tk, Canvas from PIL import ImageTk, Image from pynput.mouse import Listener from PIL import Image, ImageDraw import PIL root = Tk() #Create a canvas canvas = Canvas(root, width=1400, height=788) canvas.pack() # Load the image file im = Image.open('27.jpg') im=im.convert('RGB') # Put the image into a canvas compatible class, and stick in an # arbitrary variable to the garbage collector doesn't destroy it canvas.image = ImageTk.PhotoImage(im) # Add the image to the canvas, and set the anchor to the top left / north west corner canvas.create_image(0, 0, image=canvas.image, anchor='nw') def getorigin(eventorigin): global x,y x = eventorigin.x y = eventorigin.y colors = im.getpixel((x,y)) print(x,y,colors) drawlines() #print() #root = Tk() root.bind("