Getting pixel coordinates efficiently in Matlab

[亡魂溺海] 提交于 2019-12-07 13:00:55

问题


I would like to create a function in Matlab that, given an image, will allow one to select a pixel by clicking on it in the image and return the coordinates of the pixel. Ideally, one would be able to click on several pixels in the image in succession, and the function would store all the respective coordinates in a matrix. Is there a way to do this in Matlab?


回答1:


ginput

Graphical input from mouse or cursor Syntax

    [x,y] = ginput(n) 
    [x,y] = ginput 
    [x,y,button] = ginput(...)

Description

[x,y] = ginput(n) enables you to identify n points from the current axes and returns their x- and y-coordinates in the x and y column vectors. Press the Return key to terminate the input before entering n points.




回答2:


I think this is what you want:

A=imread('filename.jpg');
image(A)
[x,y]=ginput()


来源:https://stackoverflow.com/questions/6541444/getting-pixel-coordinates-efficiently-in-matlab

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