You can display the image to the user using the imshow()
function. To get user input via the mouse, you can use the ginput()
function. Here's an example code that displays an image in a figure window, and prompts the user to select a pixel. It also displays some directions to the user:
main.m391 chars15 lines
Note that ginput()
will wait for the user to select a pixel. The argument 1
tells the function to wait for only one user click. The coordinates of the selected pixel are returned as two separate values, x
and y
.
gistlibby LogSnag