Create a Python script (monochrome_graph.py) with the following code: import cv2 import numpy as np import matplotlib.pyplot as plt def create_color_mask(image, lower_color, upper_color): hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV) return cv2.inRange(hsv_image, lower_color, upper_color) def main(): # Read the input colored graph image input_image = cv2.imread('colored_graph.png') # Define color ranges for thresholding color_ranges = [ (np.array([0, 100, 100]), np.array([10, 255, 255])), # Red (np.array([35, 100, 100]), np.array([70, 255, 255])), # Green (np.array([100, 100, 100]), np.array([130, 255, 255])) # Blue ] # Line styles for each color line_styles = ['-', '--', '-.'] plt.figure() for i, (lower_color, upper_color) in enumerate(color_ranges): # Create a binary mask for the current color mask = create_color_mask(input_image, lower_color, upper_color) # Apply edge detection edges = cv2.Canny(mask, 50, 150) # Detect lines using HoughLinesP lines = cv2.HoughLinesP(edges, 1, np.pi/180, 100, minLineLength=100, maxLineGap=10) if lines is not None: for line in lines: x1, y1, x2, y2 = line[0] plt.plot([x1, x2], [y1, y2], line_styles[i % len(line_styles)]) # Display the monochrome graph plt.gca().invert_yaxis() plt.axis('off') plt.show() if __name__ == '__main__': main()