MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Cursor position on images

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129299] Re: Cursor position on images
  • From: spamslayer19 at gmail.com
  • Date: Sat, 29 Dec 2012 22:25:42 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <kbnijt$1bh$1@smc.vnet.net>

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. :)



  • Prev by Date: Re: Usage Messages in Mathematica
  • Next by Date: Re: question
  • Previous by thread: Re: Cursor position on images
  • Next by thread: Re: Cursor position on images