在matlab中获取像素位置 [英] getting pixel position with zoom in matlab

查看:306
本文介绍了在matlab中获取像素位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用这个函数

  im_data = rand(100,2); 
scatter(im_data(:,1),im_data(:,2),'r *')
[x,y,button] = ginput()
im_data(x,y) = [];

我想通过放大/缩小来删除[x,y]以避免删除正确的点。
有帮助吗?

解决方案

您可以使用刷牙和数据链接以交互方式 标记分并将其删除

例子:

 %#随机数据
x = rand(100,1);
y = rand(100,1);

%#scatter plot
hFig = figure;
scatter(x,y,50,'r','filled')

%#开启刷牙和链接
hBrush =刷子(hFig); set(hBrush,'Enable','on','Color','g')
linkdata(hFig,'on')

现在您可以使用画笔工具通过拖动选择矩形来选择数据点,单击鼠标右键并选择移除。由于我们将绘制的数据与实际变量相关联,因此删除的点也将反映在 x y 变量中。

请注意,您始终可以使用缩放工具来放大特定区域,然后切换到笔刷以供选择...






如上所示删除点后,我们可以检查变量:

 >> whos xy 
名称大小字节类属性

x 86x1 688 double
y 86x1 688 double


I have some 2D points on my image/figure.

I use this function

im_data= rand(100,2);
scatter(im_data(:,1),im_data(:,2),'r*')
[x,y,button] = ginput()
im_data(x,y)=[];

I want to delete [x,y] by simply zooming in / magnifying to avoid deleting correct points. Any help?

解决方案

You can use a combination of data brushing and data linking to interactively mark points and remove them from you scatter plot.

Example:

%# random data
x = rand(100,1);
y = rand(100,1);

%# scatter plot
hFig = figure;
scatter(x, y, 50, 'r', 'filled')

%# turn on brushing and linking
hBrush = brush(hFig); set(hBrush, 'Enable','on', 'Color','g')
linkdata(hFig, 'on')

Now you can use the brush tool to select data points by dragging the selection rectangle, right-click, and select remove. Since we linked the data drawn to the actual variables, the deleted points will also be reflected in the x and y variables.

Note that you can always use the zooming tool to magnify a specific region, then switch to the brush for selection...

After deleting the points as shown above, we can check the variables:

>> whos x y
  Name       Size            Bytes  Class     Attributes

  x         86x1               688  double              
  y         86x1               688  double       

这篇关于在matlab中获取像素位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆