Search code examples
matlabimage-processingmousemouseoverpixel

Obtain pixel values from an image at the mouse position


I am trying to obtain the pixel values as and when I move my mouse cursor in Maltab .Can I use g-input function in Matlab? I am not getting how to proceed. All the pixel values are doubles.


Solution

  • Does impixelinfo do what you need? This requires Image Processing Toolbox.

    Alternatively, can you just use a Data Cursor? For example, type image to display a default image. Then in the figure toolbar, click the Data Cursor button (looks like a little yellow square and a blue line, with a black crosshair). Finally click on a pixel in the image to display X and Y coordinates, and RGB values of the pixel. You can pick the data cursor up with the mouse and move it around to display other pixels.