Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13944 > unrolled thread

ImageTaker[img, {{x1,y1},{x2,y2}} ] useful toolfunction

Started byroby <roby.nowak@gmail.com>
First post2013-03-28 21:12 +0000
Last post2013-04-02 07:26 +0000
Articles 3 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  ImageTaker[img, {{x1,y1},{x2,y2}} ] useful toolfunction roby <roby.nowak@gmail.com> - 2013-03-28 21:12 +0000
    Re: ImageTaker[img, {{x1,y1},{x2,y2}} ] useful toolfunction roby <roby.nowak@gmail.com> - 2013-03-30 08:07 +0000
      Re: ImageTaker[img, {{x1,y1},{x2,y2}} ] useful toolfunction roby <roby.nowak@gmail.com> - 2013-04-02 07:26 +0000

#13944 — ImageTaker[img, {{x1,y1},{x2,y2}} ] useful toolfunction

Fromroby <roby.nowak@gmail.com>
Date2013-03-28 21:12 +0000
SubjectImageTaker[img, {{x1,y1},{x2,y2}} ] useful toolfunction
Message-ID<kj2bnf$m4u$1@smc.vnet.net>
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

[toc] | [next] | [standalone]


#13965

Fromroby <roby.nowak@gmail.com>
Date2013-03-30 08:07 +0000
Message-ID<kj66f6$ogu$1@smc.vnet.net>
In reply to#13944
Just a little bit more compact version:

ImageTaker[img_, c_] := ImageTake[img, Sequence @@ (
    c // Transpose // Reverse // Sort /@ #& // 
     MapAt[First@ImageDimensions@img - Reverse@#&, #, 1]&)]


Robert

[toc] | [prev] | [next] | [standalone]


#14022

Fromroby <roby.nowak@gmail.com>
Date2013-04-02 07:26 +0000
Message-ID<kje16j$h0c$1@smc.vnet.net>
In reply to#13965
Am Samstag, 30. M=E4rz 2013 09:07:02 UTC+1 schrieb roby:
> Just a little bit more compact version:
>
>
>
> ImageTaker[img_, c_] := ImageTake[img, Sequence @@ (
>
>     c // Transpose // Reverse // Sort /@ #& //
>
>      MapAt[First@ImageDimensions@img - Reverse@#&, #, 1]&)]
>
>
>
>
>
> Robert

Ok just, learned that starting with Mathematica 8

ImageTrim[]

does the miracle.

thx to Matthias Odisio

Robert

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web