【问题标题】:A second matlab figure based on pixel coordinate data on the first figure基于第一个图上的像素坐标数据的第二个matlab图
【发布时间】:2015-10-14 19:20:31
【问题描述】:

我有一个imagesc 图像,其中每个像素代表一个数据向量。图像本身来自压缩成二维矩阵的数据立方体。我可以使用impixelinfo 在图像中导航并在查询图像时获取像素坐标。执行代码如下,

load data.mat; % data cube of size 512x256x12000
figure; imagesc(squeeze(mean(abs(data),3)))
axis equal; colormap jet;
impixelinfo

我想要做的是能够使用像素坐标在第二个图中绘制基础数据向量(位于第三维)。当我在图像中移动光标时,第二个图形应该会自动更新。

非常感谢任何帮助。先感谢您。

【问题讨论】:

  • 请在您的代码中添加minimal reproducible example,否则我们将在漆黑的洞穴中抓住稻草。
  • 你可以通过WindowButtonMotionFcn回调来实现

标签: matlab


【解决方案1】:

谢谢大家,我找到了ButtonDownFcn 的解决方案,并在此处发布给有类似问题的人们。

x = (-10:10); y = x; z = x;
[mx, my, mz] = ndgrid(x,y,z)
r = sqrt(mx.^2 + my.^2 + mz.^2);
figure;
imagesc(squeeze(r(:,:,1)),'ButtonDownFcn', {@test_func,r});

具有以下功能

function test_func(hObject, eventdata, r);
P = get(gca,'CurrentPoint');
X = round(P(1,1));Y = round(P(1,2));
figure;plot(squeeze(r(X,Y,:)));
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-01
    • 1970-01-01
    相关资源
    最近更新 更多