Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: interactive dragrect over a raster image

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89629] Re: interactive dragrect over a raster image
  • From: "David Park" <djmpark at comcast.net>
  • Date: Sun, 15 Jun 2008 06:14:59 -0400 (EDT)
  • References: <g3038u$mei$1@smc.vnet.net>

Here is one solution. I make the width and height of the rectangle
dynamically adjustable. The red point is a locator to position the
rectangle. You could add another plot in a row to give a histogram analysis,
but since I don't know what that might be I simply  output the number of
points in the rectangle.

data = RandomReal[{0, 10}, {100, 2}];

DynamicModule[
 {pt = {0, 0}, width = 2., height = 1.},
 Column[{
   Item[Style["Analysis With Data Sampler", "Panel", Large,
     Background -> None], Alignment -> Center],
   Row[{"width: ", InputField[Dynamic[width], ImageSize -> {60, 20}],
     Spacer[10], "height: ",
     InputField[Dynamic[height], ImageSize -> {60, 20}], Spacer[10],
     "center: ",
     Dynamic@NumberForm[pt + {width, height}/2, {4, 2}]}],
   Row[{"Point count in sample: ",
     Dynamic@Length@
       Select[data,
        First[pt] <= First[#] <= First[pt] + width \[And]
          Last[pt] <= Last[#] <= Last[pt] + height &]}],
   Graphics[
    {Yellow, Dynamic@Rectangle[pt, pt + {width, height}],
     Black, AbsolutePointSize[3], Point /@ data,
     Locator[Dynamic[pt],
      Graphics[{Red, AbsolutePointSize[6], Point[{0, 0}]}]]},
    Frame -> True,
    PlotRange -> {{0, 10}, {0, 10}},
    PlotRangePadding -> 1,
    ImageSize -> 400](* Graphics *)
   }](* Column *)
 ]


-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


"rych" <rychphd at gmail.com> wrote in message 
news:g3038u$mei$1 at smc.vnet.net...
>I would like to be able to drag a rectangle with mouse over a raster
> image plot and dynamically update another plot, a histogram, for
> example, for the corresponding region? Something like Slider2D on the
> background of the image? Or is it better to program it using NETLink,
> or something?
> Igor
> 



  • Prev by Date: Re: Re: export pdf font question
  • Next by Date: Re: How to make an InputField inside of a graphic active...
  • Previous by thread: Re: interactive dragrect over a raster image
  • Next by thread: Re: interactive dragrect over a raster image