Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image, ImageDraw, ImageOps
- # Load the image
- image_path = "/mnt/data/tzaYiWe.jpeg"
- original_image = Image.open(image_path).convert("L")
- # Invert the image to make the line black on a white background
- inverted_image = ImageOps.invert(original_image)
- # Create a new image with a white background to draw the blueprint elements
- blueprint = Image.new("RGB", inverted_image.size, (255, 255, 255))
- draw = ImageDraw.Draw(blueprint)
- # Copy the original line to the new image
- blueprint.paste(inverted_image, (0, 0))
- # Adding typical elements found in a racing circuit blueprint
- # These are simple representations and can be more detailed
- # Start/Finish line
- start_finish_line_coords = [(int(inverted_image.width * 0.45), int(inverted_image.height * 0.5)),
- (int(inverted_image.width * 0.55), int(inverted_image.height * 0.5))]
- draw.line(start_finish_line_coords, fill="blue", width=3)
- # Pit lane (a simple straight line near the start/finish line)
- pit_lane_coords = [(int(inverted_image.width * 0.45), int(inverted_image.height * 0.55)),
- (int(inverted_image.width * 0.55), int(inverted_image.height * 0.55))]
- draw.line(pit_lane_coords, fill="blue", width=3)
- # Spectator stands (rectangles near the circuit)
- stands_coords = [
- (int(inverted_image.width * 0.2), int(inverted_image.height * 0.4), int(inverted_image.width * 0.3), int(inverted_image.height * 0.45)),
- (int(inverted_image.width * 0.7), int(inverted_image.height * 0.4), int(inverted_image.width * 0.8), int(inverted_image.height * 0.45))
- ]
- for stand in stands_coords:
- draw.rectangle(stand, outline="blue", width=3)
- # Convert to blueprint style by adding a blue filter
- blueprint = ImageOps.colorize(blueprint.convert("L"), black="white", white="blue")
- blueprint.show()
Advertisement
Add Comment
Please, Sign In to add comment