MJ_Agassi551

blueprint_chatgpt_image_track001

May 29th, 2024
740
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.80 KB | None | 0 0
  1. from PIL import Image, ImageDraw, ImageOps
  2.  
  3. # Load the image
  4. image_path = "/mnt/data/tzaYiWe.jpeg"
  5. original_image = Image.open(image_path).convert("L")
  6.  
  7. # Invert the image to make the line black on a white background
  8. inverted_image = ImageOps.invert(original_image)
  9.  
  10. # Create a new image with a white background to draw the blueprint elements
  11. blueprint = Image.new("RGB", inverted_image.size, (255, 255, 255))
  12. draw = ImageDraw.Draw(blueprint)
  13.  
  14. # Copy the original line to the new image
  15. blueprint.paste(inverted_image, (0, 0))
  16.  
  17. # Adding typical elements found in a racing circuit blueprint
  18. # These are simple representations and can be more detailed
  19. # Start/Finish line
  20. start_finish_line_coords = [(int(inverted_image.width * 0.45), int(inverted_image.height * 0.5)),
  21.                             (int(inverted_image.width * 0.55), int(inverted_image.height * 0.5))]
  22. draw.line(start_finish_line_coords, fill="blue", width=3)
  23.  
  24. # Pit lane (a simple straight line near the start/finish line)
  25. pit_lane_coords = [(int(inverted_image.width * 0.45), int(inverted_image.height * 0.55)),
  26.                    (int(inverted_image.width * 0.55), int(inverted_image.height * 0.55))]
  27. draw.line(pit_lane_coords, fill="blue", width=3)
  28.  
  29. # Spectator stands (rectangles near the circuit)
  30. stands_coords = [
  31.     (int(inverted_image.width * 0.2), int(inverted_image.height * 0.4), int(inverted_image.width * 0.3), int(inverted_image.height * 0.45)),
  32.     (int(inverted_image.width * 0.7), int(inverted_image.height * 0.4), int(inverted_image.width * 0.8), int(inverted_image.height * 0.45))
  33. ]
  34. for stand in stands_coords:
  35.     draw.rectangle(stand, outline="blue", width=3)
  36.  
  37. # Convert to blueprint style by adding a blue filter
  38. blueprint = ImageOps.colorize(blueprint.convert("L"), black="white", white="blue")
  39.  
  40. blueprint.show()
  41.  
Advertisement
Add Comment
Please, Sign In to add comment