我有一个像这样的月亮图像:moon picture from normal camera lens
我想沿着y轴上的一条固定值的线绘制强度分布图,该线沿着图像如下所示:image above with line across a fixed y coordinate
我希望能够通过在Python代码中输入坐标来指定坐标的起点和终点。我找到了一种方法,可以通过单击鼠标和其他方法来完成此操作,但是无法获得仅沿着同一条线的轮廓,因为我需要比较此图像在特定y值处的轮廓。到另一个图像在相同的值y。使用点击是innacurate和我不能复制的结果。
我该怎么做?
我可以对另一个图像执行此操作,但无法去除剖面图中的红线(请参见下面的代码)
another image and profile
其他图像和配置文件的代码:
from matplotlib import pyplot as plt
from skimage.measure import profile_line
from skimage.io import imread
image = imread(r".....path to image....\moon2.png")
start = (210, 100) #Start of the profile line row=100, col=0
end = (210, 410) #End of the profile line row=100, col=last
profile = profile_line(image, start, end)
fig, ax = plt.subplots(1, 2)
ax[0].set_title('Image')
ax[0].imshow(image)
ax[0].plot([start[1], end[1]], [start[0], end[0]], 'r')
ax[1].set_title('Profile')
ax[1].plot(profile)
plt.rcParams["figure.figsize"] = (30,70)
1条答案
按热度按时间ep6jt1vc1#
你可以使用“hyperspy”包来轻松地做到这一点。可能有更直接的(常用的包)做同样的事情。我不是Maven,但以下肯定会工作。
首先,加载图像
然后绘制它。
然后使用x1,y1,x2,y2定义二维线对象
沿着定义的线交互提取数据
您可以在同一图形上绘制线条轮廓
有关详细信息,请参阅此处:http://hyperspy.org/hyperspy-doc/current/user_guide/visualisation.html#plotting-several-signals