Message Boards Message Boards

How do I get ImageData while using MousePosition?

Posted 9 years ago

I am trying to get the rgb values of the rose while the mouse is moving. As you see, this doesn't work:

rose = Import["ExampleData/rose.gif"];

idrose = ImageDate[rose];


rrose = Rasterize[rose]

dmp = Dynamic[MousePosition[]]

ImageData[rose[[Flatten[dmp]  ]]  ]
POSTED BY: Douglas Youvan

This doesn't work for a number of reasons:

MousePosition is in Pixels form the entire screen, not from the image. And you assigned your dmp to something Dynamic, but it can then not be used like that in the last line.

It would be something like:

Dynamic[ImageData[rose[[Flatten[MousePosition[]]]]]

I'm not sure though that you can get the MouseCoordinates back in Pixels! Perhaps try using MousePosition["Graphics"]

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract