图像强度剖面缺失右端无法显示预期7个峰值如何解决
问题原因及解决方法
核心原因1:剖面线可视化代码错误
你当前用于绘制红线的代码逻辑不符合matplotlib的plot函数参数要求:ax.plot()的入参规则是plot([x坐标列表], [y坐标列表]),而skimage的坐标格式是(行号, 列号),对应(y坐标, x坐标),你直接传入(start, end)会导致绘制的红线和实际提取剖面的路径完全不匹配,你看到的红线位置不是实际提取强度的路径。
核心原因2:端点未完全覆盖/包含
- 你当前设置的
end = (100, 100)路径未覆盖到第7个峰值所在的区域 - 可显式指定
profile_line的endpoint=True参数确保右端点被纳入剖面计算
修正后的代码
from matplotlib import pyplot as plt from skimage.measure import profile_line from skimage.io import imread # 坐标格式为(行号, 列号),可根据实际7个峰的覆盖范围调整end坐标 start = (0, 714) end = (300, 0) # 示例:调大行号让路径覆盖所有条纹,可自行根据图像调整数值 image = imread('你的图像路径.tif') # 显式指定endpoint=True确保右端点被包含 profile = profile_line(image, start, end, linewidth=1, mode='constant', endpoint=True) fig, ax = plt.subplots(2, 1, figsize=(10, 10)) ax[0].imshow(image) # 修正剖面线绘制逻辑:x是列号,y是行号 ax[0].plot([start[1], end[1]], [start[0], end[0]], 'r-', lw=2) ax[1].plot(profile) ax[1].grid() plt.show()
参考图像
原运行结果图

待处理胶片原图

内容的提问来源于stack exchange,提问作者Filippos
相关产品推荐
相关产品推荐

