Re: locating max value on the image

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

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). In[1]:= 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 & ]] In[4]:= Length /@ Table[myMax[g, 10^(-n)], {n, 0, 10}] Out[4]= {112, 79, 41, 14, 4, 2, 1, 1, 1, 1, 1} In[5]:= myMax[g, 10^(-4)] Out[5]= {{1.56881, 0.999998}, {7.84112, 0.999917}, {14.1231, 0.999901}, {20.4209, 1.}} Regards, Jean-Marc