I aim to select points in a specific order using markers. Imagine selecting edges of a chessboard for example ( I know that there are automatic techniques using opencv but I need a manual option).
Using the following piece of code, I can plot markers over an image. I would like to enumerate the markers with their corresponding order in the list x
and y
.
import matplotlib.pyplot as plt
import numpy as np
img = plt.imread("image.png")
x = np.random.rand(1, 20)*img.shape[1]
y = np.random.rand(1, 20)*img.shape[0]
size = 50
plt.imshow(img, cmap="gray") # plot image
plt.scatter(x, y, size, c="r", marker="+") # plot markers
plt.show()
This is an example of how my desired result should look like:
Wouldn't it work to just place a text next to each point?
Like so
import matplotlib.pyplot as plt
import numpy as np
img = plt.imread("patrick.webp")
x = np.random.rand(20) * img.shape[1]
y = np.random.rand(20) * img.shape[0]
size = 50
plt.imshow(img, cmap="gray")
plt.scatter(x, y, size, c="r", marker="+")
for i, (x_coord, y_coord) in enumerate(zip(x, y)):
plt.text(x_coord, y_coord, str(i+1), fontsize=12, color="yellow", ha="left")
plt.show()