Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Cursor position on images
Replies: 3   Last Post: Dec 30, 2012 8:49 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
spamslayer19@gmail.com

Posts: 6
Registered: 12/29/12
Re: Cursor position on images
Posted: Dec 29, 2012 10:24 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Saturday, December 29, 2012 2:08:29 PM UTC-6, King, Peter R wrote:
> I am sure this is straightforward but I cannot quite see how to do this.
I have an image (jpg file, but could be any format if that matters). I want
to be able to left click on the image and mark the point with a dot of some sort and collect the coordinates of the point (the coordinate system is fairly arbitrary). I then want to be able to repeat this as many times as required and end up with a list of the coordinates of the points clicked on for further manipulation. Clickpane should do the trick but I can't work out how.
>
>
>
> Any suggestions, thanks.
>
>
>
> Peter


Try this:

image = ExampleData[{"TestImage", "Girl3"}];
ptColor = Yellow;
ptSize = Large;
Panel@Grid[
{
{
Dynamic@ClickPane[
Show[
{
image, Graphics[{PointSize[ptSize], ptColor, Point[ptsList]}]
}
],
AppendTo[ptsList, #] &], SpanFromLeft
},
{
PopupWindow[Button["View Points", ImageSize -> 100],
Dynamic@ptsList], SpanFromLeft
},
{
Button["Reset", ptsList = {}, ImageSize -> 100], SpanFromLeft
}
},
Alignment -> {Right, Baseline}
]

If you don't like the popup window, you can just evaluate Dynamic@ptsList in a separate cell. I'm sure someone has a more elegant solution, but this works. :)




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.