【问题标题】:Pixel intensity values along imline segment in MatlabMatlab中沿imline段的像素强度值
【发布时间】:2016-07-02 16:19:44
【问题描述】:

考虑使用一些通用描述的 Matlab imagesc() 轴显示的图像,例如 10x10 像素,其中每个像素的强度值在 [0 255]

使用图像分析工具包中的 imline() 方法,我想沿用户交互定义的线检索像素强度值。俗称“线型材”。这里的重要区别是平行于 X 或 Y 轴的线是不够的。这条线必须由用户以交互方式绘制。

到目前为止,我已经研究了 Matlab 方法 improfile()impixel(),但到目前为止我还没有得到想要的结果。

【问题讨论】:

  • improfile 正是这样做的。你在哪里遇到困难?
  • Maube 与交互式输入。在这种情况下,为 axes 查找 callback 操作。
  • @Crowley Callbacks for axes 解决了我所有的问题。谢谢你。如果您希望我对您的建议进行投票,请将其作为解决方案发布。

标签: matlab image-processing pixels


【解决方案1】:

这段代码读取图像 (objectHandle) 的点击位置并更新文本框中的行 (currentLine 句柄) 值和字符串 (Coords 句柄)。

%% Code here
axis tight
imageHandle = imshow('input\foo.jpg');
set(imageHandle,'ButtonDownFcn',{@ImageClickCallback,Coords,currentLine});
%% Code there

function ImageClickCallback (objectHandle,~,Coords,currentLine)
axesHandle  = get(objectHandle,'Parent');
coordinates = get(axesHandle,'CurrentPoint');   %// This line reads the click
coordinates = coordinates(1,1:2);
LineX=get(currentLine,'xdata');
LineY=get(currentLine,'ydata');
set(currentLine,'xdata',[LineX,coordinates(1)])
set(currentLine,'ydata',[LineY,coordinates(2)])

set(Coords.X,'string',{'X';num2str(coordinates(1),'%.0f')})
set(Coords.Y,'string',{'Y';num2str(coordinates(2),'%.0f')})

end

【讨论】:

    猜你喜欢
    • 2017-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-01
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多