from nptdms import TdmsFile as td
from matplotlib import pyplot as plt
import numpy as np
import skimage.color
import skimage.filters
import mplcursors
from skimage.feature import corner_harris,corner_peaks
file = 'sample.tdms'
with td.open(file) as tdms_file:
img = tdms_file.as_dataframe()
cropped_list = []
sel=cropped_list.append(img.iloc[700:1250,450:1550:])
coords=corner_peaks(corner_harris(sel),min_distance=10,threshold_rel=0.02)
fig, ax = plt.subplots()
ax.imshow(sel, cmap='gray')
plotted_points =ax.plot(coords[:, 1], coords[:, 0], color='cyan', marker='o',linestyle='None', markersize=2)
mplcursors.cursor(plotted_points, hover=True)
plt.show(
我尝试使用 mplcursors。但是当鼠标悬停时,绘图上没有显示任何内容。箭头未显示任何坐标。我尝试只绘制没有图像的点,但它仍然没有显示任何坐标。
[108 162] [ 65 397] [212 552] [ 62 645] [109 550] [256 240] [283 24] [185 552] [286 86] [186 242] [355 180] [141 550] [64 707] [283 704] [285 330] [257 398] [185 398] [285 398] [109 126] [356 89] [37 709] [64 331] [111 316] [35 334] [214 487] [328 241] [119 172] [212 88] [356 244] [253 332] [39 240] [328 27] [359 395] [77 266] [358 641] [211 642] [110 706] [181 151] [140 396] [110 332] [64 489] [182 486] [328 396] [254 485] [195 274] [256 549] [111 83] [328 639] [253 179] [339 270] [206 135] [325 488]] 这是坐标数组。那么如何根据图像的形状将坐标保存在变量中。只有第一行中的矩形。我的图像是一系列矩形传感器。这就是为什么我试图通过鼠标点击找到坐标。