画直线

  1. x1 = [200, 500]
  2. y1 = [300, 100]
  3. plt.figure()
  4. plt.subplot(121),plt.imshow(roi1)
  5. plt.plot(x1, y1, color="dodgerblue", linewidth=3)
  6. plt.plot(x2, y2, color="orange", linewidth=3)
  7. plt.plot(x3, y3, color="red", linewidth=3)

画矩形框

  1. rect = patches.Rectangle((450, 770), 150, 150, linewidth=3, edgecolor='r', facecolor='none')
  2. plt.gca().add_patch(rect)

image.png

Reference

  1. https://www.geeksforgeeks.org/plot-a-point-or-a-line-on-an-image-with-matplotlib/
  2. https://stackoverflow.com/questions/37435369/matplotlib-how-to-draw-a-rectangle-on-image