Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def picture_reset_pixels(filename, from_color, to_color, target_color):
- img = Image.open(filename)
- pixels = list(img.getdata())
- red_list=[]
- for i in pixels:
- R= i[0]
- G=i[1]
- B=i[2]
- if R >= from_color[0] and R<= to_color[0] and G >=from_color[1]
- and G<= to_color[1] and B >= from_color[2] and B<=
- to_color[2]:
- red_list.append(target_color)
- else:
- red_list.append((round(R),round(G),round(B)))
- red_image = Image.new(img.mode,img.size)
- red_image.putdata(red_list)
- return red_image
Add Comment
Please, Sign In to add comment