Re: useful toolfunction
- To: mathgroup at smc.vnet.net
- Subject: [mg130317] Re: useful toolfunction
- From: Matthias Odisio <matthias at wolfram.com>
- Date: Tue, 2 Apr 2013 03:29:49 -0400 (EDT)
- 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: <20130328155438.1A01169EF@smc.vnet.net>
Dear Robert,
On 3/28/13 10:54 AM, roby wrote:
> Dear Mathematica user
>
> sometimes it would be helpful to use the coordinate picker tool
> of the 2D Drawing toolbox to be able to extract a subimage of an
> image displayed in the frontend.
>
> The problem here ist that the picker tool gives you x,y coordinates
> with y positive direction growing from bottom to top.
> Whereas ImageTake first needs row indices growing top to bottom
> followed by column indices.
>
> The following function provides most of what is needed:
>
>
>
> ImageTaker[img_, c_] :=
> ImageTake[img, Sequence @@ ({First@ImageDimensions@img, 0} +
> (c // Transpose // Sort /@ # & // MapAt[-Reverse@# &, #, 2] & //
> Reverse))]
>
>
>
> ImageTaker accepts 2 paramters the first one is the source image, the second
> is the x,y coordinate pair specifying the subimage.
>
> So the procedure is the following:
> pick twice inside the source image using the coordinate picker tool,
> copy the coordinates by pressing CTRL-C,
> paste the coordinates CTRL-V to the function above as second parameter,
> feed the source imgage as first parameter e.g.
> by referencing an output cell containing the image
> by %nnn and evaluate it.
>
> this gives you something like this:
>
> ImageTaker[%nnn,{{x1,y1},{x2,y2}}]
>
> which will evaluate and display the desired subimage.
>
> Robert
>
Did you have a look at ImageTrim? It should help.
Matthias Odisio
Wolfram Research