getting pixel position with zoom in matlab

六月ゝ 毕业季﹏ 提交于 2019-12-24 11:40:16

问题


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?


回答1:


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       


来源:https://stackoverflow.com/questions/7455189/getting-pixel-position-with-zoom-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!