I  want you to modify the code such that the output image should be in a color format not grayscale.def read_input():

    img = cv2.imread('/content/map2.png', cv2.IMREAD_GRAYSCALE)

    start = (50,50)
    goal = (400,400)

    return img, start, goalclass RRTNode:
    def __init__(self, x, y, parent=None):
        self.x = x
        self.y = y
        self.parent = parent


# Initialize the RRT tree with the starting point:

def initialize_RRT(start):
    start_node = RRTNode(start[0], start[1])
    tree = [start_node]
    return tree


### Step 4: Define a function to sample new points

def random_sample(img):
    h, w = img.shape
    x = random.randint(0, w - 1)
    y = random.randint(0, h - 1)

    while img[y, x] == 0:
        x = random.randint(0, w - 1)
        y = random.randint(0, h - 1)

    return x, y


### Step 5: Define a function to calculate the nearest vertex

def nearest_node(tree, point):
    min_distance = sys.maxsize
    nearest = None
    for node in tree:
        distance = math.sqrt((node.x - point[0])**2 + (node.y - point[1])**2)
        if distance < min_distance:
            min_distance = distance
            nearest = node
    return nearest


### Step 6: Define a function to steer/control between points

def control_steer(node, point, step_size=10):
    dist = math.sqrt((node.x - point[0])**2 + (node.y - point[1])**2)

    if dist <= step_size:
        return point

    else:
        ratio = step_size / dist
        x_new = int(node.x + ratio * (point[0] - node.x))
        y_new = int(node.y + ratio * (point[1] - node.y))

        return x_new, y_new


### Step 7: Define a function to check for obstacles between two points

def obstacle_free(img, point1, point2):
    for t in np.arange(0., 1., 0.001):
        x = int((1 - t) * point1[0] + t * point2[0])
        y = int((1 - t) * point1[1] + t * point2[1])
        if img[y, x] == 0:
            return False
    return True


### Step 8: Implement the main RRT loop

def build_RRT(img, tree, goal):
    max_iterations = 1000
    found_goal = False
    goal_node = None

    for _ in range(max_iterations):
        x_rand, y_rand = random_sample(img)

        nearest = nearest_node(tree, (x_rand, y_rand))

        x_new, y_new = control_steer(nearest, (x_rand, y_rand))

        if obstacle_free(img, (nearest.x, nearest.y), (x_new, y_new)):
            new_node = RRTNode(x_new, y_new, parent=nearest)
            tree.append(new_node)

            if obstacle_free(img, (x_new, y_new), goal):
                goal_node = RRTNode(goal[0], goal[1], parent=new_node)
                found_goal = True
                break

    return found_goal, goal_node


### Step 9: Reconstruct the path

def reconstruct_path(goal_node):
    path = []
    current = goal_node
    while current is not None:
        path.append((current.x, current.y))
        current = current.parent
    return path[::-1]


### Step 10: Draw the start and goal circles, sampled nodes and links, and the final path

# def draw_RRT(img, tree, start, goal, path, file_name='map_name.png'):
#     for node in tree:
#         if node.parent is not None:
#             cv2.line(img, (node.x, node.y), (node.parent.x, node.parent.y), (0, 255, 0), 1)

#     for node in tree:
#         cv2.rectangle(img, (node.x-1, node.y-1), (node.x+1, node.y+1), (0, 0, 255), -1)

#     for i in range(len(path) - 1):
#         cv2.line(img, path[i], path[i+1], (255, 0, 0), 2)

#     cv2.circle(img, start, 5, (0, 255, 255), -1)
#     cv2.circle(img, goal, 5, (0, 255, 255), -1)

#     cv2.imwrite(file_name, img)
def draw_RRT(img, tree, start, goal, path, file_name='output_map.png'):
  """
  Draws the RRT graph on the given image.

  Args:
    img: The image to draw the graph on.
    tree: The RRT graph.
    start: The start position of the graph.
    goal: The goal position of the graph.
    path: The path from the start to the goal position.
    file_name: The file name to save the image to.
  """

  # Convert the colors to the BGR format.
  blue = (0, 0, 255)
  red = (0, 0, 255)
  green = (0, 255, 0)

  # Draw the path in blue.
  for i in range(len(path) - 1):
    cv2.line(img, path[i], path[i + 1], blue, 2)

  # Draw the start and goal points in red.
  cv2.circle(img, start, 5, red, -1)
  cv2.circle(img, goal, 5, red, -1)

  # Draw the tree links in green.
  for node in tree:
    if node.parent is not None:
      cv2.line(img, (node.x, node.y), (node.parent.x, node.parent.y), green, 1)

  # Draw the tree nodes in red.
  for node in tree:
    cv2.rectangle(img, (node.x - 1, node.y - 1), (node.x + 1, node.y + 1), red, -1)

  # Save the image.
  rgb_image = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
  cv2.imwrite(file_name, rgb_image)


### Step 11: Save the output image

if __name__ == '__main__':
    img, start, goal = read_input()
    tree = initialize_RRT(start)
    found_goal, goal_node = build_RRT(img, tree, goal)

    if found_goal:
        path = reconstruct_path(goal_node)
        draw_RRT(img, tree, start, goal, path)
    else:
        print('No path found.')