MathGroup Archive 2009

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

Search the Archive

Re: distorting an image

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105362] Re: [mg105324] distorting an image
  • From: Mark McClure <mcmcclur at unca.edu>
  • Date: Sun, 29 Nov 2009 05:12:01 -0500 (EST)
  • References: <200911280605.BAA01372@smc.vnet.net>

On Sat, Nov 28, 2009 at 3:34 PM, Leon Gunther <thegunthers at rcn.com> wrote:
> More details:
> Map an image that occupies a circular area with 5 units
> radius onto a circle with a smaller radius (see below). The
> mapping is circularly symmetric, so that we only rescale the
> radius from the center of the image:
>  r' = tan { arcsin[ (3/4)*sin(pi*r/10) ] }

First, your use of the word "image" is unclear to me.  Better
would be Graphics or Image or some Mathematica type that you
want to manipulate.  Even better would be a specific object
that you want to manipulate.  In my original reply, I was
assuming that you wanted to work with an Image, i.e. a
Mathematica representation of a photographic image.  Perhaps
this is not correct so here's a simple, rotationally
symmetric Graphics object to play with:

m = 18;
supplement[{a_, b_}] := Table[a*(1 - t) + b*t, {t, 0, 1, 0.1}];
baseTriangles[n_] := Table[triangle[
    {{n - 1 - k (1 - Cos[2 Pi/m]), k Sin[2 Pi/m]},
     {n - k (1 - Cos[2 Pi/m]), k Sin[2 Pi/m]},
     {Cos[2 Pi/m] + n - 1 - k (1 - Cos[2 Pi/m]),
      Sin[2 Pi/m] + k Sin[2 Pi/m]},
     {n - 1 - k (1 - Cos[2 Pi/m]), k Sin[2 Pi/m]}}], {k, 0, n - 1}];
ring[n_] := Table[baseTriangles[n] /. triangle[vs_] :>
     triangle[RotationMatrix[t].# & /@ vs],
   {t, 0, 2 Pi - 2 Pi/m, 2 Pi/m}];
pic = Graphics[ring /@ Range[5] /. triangle[{a_, b_, c_, a_}] ->
    Line[Flatten[{supplement[{a, b}], supplement[{b, c}],
       supplement[{c, a}]}, 1]], Axes -> True]


The details of the graphic are not really particularly
important.  We simply need to operate on each numeric
pair {x,y}.  We can do this like so:

Clear[f];
f[r_] := Tan[ArcSin[(3/4) Sin[Pi (r/10)]]];
f[{0., 0.}] = f[{0, 0}] = {0, 0};
f[{x_?(# != 0 &), y_?(# != 0 &)}] :=
  f[Norm[{x, y}]] {x, y}/Norm[{x, y}];
pic /. {x_?NumericQ, y_?NumericQ} :> f[{x, y}]


> Why the INTEREST?
> This mapping approximately maps an image on a hemispherical
> surface ( 5 units radius) of wall in the air above a water
> surface onto the corresponding image that one would see from
> within the water at a depth of one unit. The distortion is
> due to refraction.

Interesting, in fact the formula looks semi-familiar to me
from a long past physics course.

> Question: Where is your image "tree" stored. Is it a
> standard image in Mathematica?

Like most of the *Data commands in Mathematica, ExampleData
accesses servers at Wolfram Research.  There are 9 different
types of ExampleData, as listed by the command ExampleData[].
One of these is types is "TestImage" and there are 44 such
images, as listed by the command ExampleData["TestImage"].
To see all of them, simply issue the command:
{#, ExampleData[#]} & /@ ExampleData["TestImage"]
This might take a bit of time to run the first time, as the
images are all loaded, but they will be cached on your
hard drive and accessed more quickly next time.

Hope that helps,
Mark McClure


  • Prev by Date: Re: Bug ??????
  • Next by Date: Re: Bug ??????
  • Previous by thread: Re: distorting an image
  • Next by thread: Re: distorting an image