# How do I get ImageData while using MousePosition?

**URL:** <https://community.wolfram.com/t/how-do-i-get-imagedata-while-using-mouseposition/7288>\
**Category:** Questions\
**Tags:** data-science, image-processing, interface-construction, ui-ux-and-ide\
**Created:** [November 22, 2015, 2:49pm UTC](https://community.wolfram.com/t/how-do-i-get-imagedata-while-using-mouseposition/7288 "2015-11-22T14:49:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/doug/32/9648_2.png) [@doug](https://community.wolfram.com/u/doug)\
**Post date:** [November 22, 2015, 2:49pm UTC](https://community.wolfram.com/t/how-do-i-get-imagedata-while-using-mouseposition/7288/1 "2015-11-22T14:49:23Z")

</div>

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] ]] ]

```

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [November 22, 2015, 4:30pm UTC](https://community.wolfram.com/t/how-do-i-get-imagedata-while-using-mouseposition/7288/2 "2015-11-22T16:30:21Z")

</div>

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"]`
