MathGroup Archive 2007

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

Search the Archive

Re: locating max value on the image

  • To: mathgroup at
  • Subject: [mg75341] Re: locating max value on the image
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at>
  • Date: Wed, 25 Apr 2007 05:45:11 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <f0kbkn$que$>

essedra wrote:
> How can I obtain where the maximum point is located on the image?
> Appreciate any comments.

Out of context, your question is very imprecise.

What is the format of the image you are using? Bitmap images are not 
encoded the same way as vector graphics. Even bitmaps have different 
formats/structures (think BMP vs. JPEG).

What do you mean by /the/ maximum point?

Let's take a simple case where the image is a 2D plot created by 
Mathematica. On the given interval, the function sin has four maximums. 
Depending on numerical imprecision, the can get one, two, tree, four, or 
more "maximum" points and even in the case of just one, we do not know 
witch one is going to be returned (that is not necessarily the first one).

g = Plot[Sin[x], {x, 0, 8*Pi}];

myMax[g_, eps_] := Module[{pts, max},
   pts = Cases[g[[1]], {(x_)?NumericQ, (y_)?NumericQ}, Infinity];
   max = Max[pts[[All,2]]];
   Select[pts, max - eps < #1[[2]] < max + eps & ]]

Length /@ Table[myMax[g, 10^(-n)], {n, 0, 10}]

{112, 79, 41, 14, 4, 2, 1, 1, 1, 1, 1}

myMax[g, 10^(-4)]

{{1.56881, 0.999998}, {7.84112, 0.999917},
  {14.1231, 0.999901}, {20.4209, 1.}}


  • Prev by Date: Re: FourierTransform and removable singularities (2nd workaround!)
  • Next by Date: Re: Re: strange behavior of Integrate
  • Previous by thread: Re: locating max value on the image
  • Next by thread: CrossProduct in Spherical Coordinates