Want to get these values in my code
1 view (last 30 days)
Show older comments
i need these values in my code ..
when i select the mouse courser on a point . it automatically pass to my code
0 Comments
Accepted Answer
Image Analyst
on 11 May 2015
If you just want to see the values on your GUI as you mouse around, use impixelinfo().
If you want to click on some pixels and get the values in an array, use impixel():
impixel(I) returns the value of pixels in the specified image I, where I can be a grayscale, binary, or RGB image. impixel displays the image specified and waits for you to select the pixels in the image using the mouse. If you omit the input arguments, impixel operates on the image in the current axes.
Use normal button clicks to select pixels. Press Backspace or Delete to remove the previously selected pixel. To finish selecting pixels, adding a final pixel, press shift-click, right-click, or double-click. To finish selecting pixels without adding a final pixel, press Return.
When you finish selecting pixels, impixel returns an m-by-3 matrix of RGB values in the supplied output argument. If you do not supply an output argument, impixel returns the matrix in ans. impixel always returns pixel values as RGB triplets, regardless of the image type:
More Answers (1)
Walter Roberson
on 11 May 2015
You can use ginput() if you want to wait for the user to click. If you want the user to be able to click as one possible action, then see the documentation for Image Properties and set a ButtonDownFcn callback in which you get() the figure CurrentPoint property to figure out where on the figure you are and deduce your image location from there (I have probably forgotten a better way)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!