MathGroup Archive 2010

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

Search the Archive

Re: Problem with Min Max between two functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111435] Re: Problem with Min Max between two functions
  • From: "J. Batista" <jbatista800 at gmail.com>
  • Date: Sun, 1 Aug 2010 04:57:21 -0400 (EDT)

Dean Maria, here is a possible solution to your question.  The white contour
areas can be removed by approaching the output of ContourPlot as an image,
treating the task as one of image processing (as suggested previously by
Daniel Lichtblau).  First, equate the original ContourPlot output with a
variable name, for example originalPlot == Out[1]  (where Out[1] is the
ContourPlot output cell).  Alternatively, you can simply select the
ContourPlot, copy and then paste into the first line of the code sequence
below in place of the variable originalPlot.  I will now display the four
lines of the code sequence and then explain them afterwards.

originalColorData == ImageData[originalPlot];

targetPixels == Position[originalColorData, originalColorData[[180, 180]]];

newColorData == ReplacePart[originalColorData, targetPixels -> {1., 1., 1.}];

Image[newColorData]


The first code line accomplishes the task of collecting and reading the
ContourPlot into computer memory as image data, in this case a vector of RGB
color values.  Note that I place a semicolon at the end of this and other
lines of code in order to suppress the visual output of the code sequence's
result.  This is because the vector is lengthy and will clog the notebook
unnecessarily.
The second code line establishes the pattern by which the portions of the
plot that you wish to alter are identified as a subset of the entire
original data set.  The pattern is established by entering the pixel
coordinate of a representative target pixel that you wish to alter, in this
case [[180, 180]] being one of the pixels in the white contour areas.  You
can determine an appropriate pixel coordinate by right-clicking in the
original ContourPlot output, selecting Get Indices, and then guiding your
cursor to a desired location within the plot.
The third code line replaces the pixel locations flagged by the previous
pattern search with new pixel data, in this case new RGB color values that
you select.  I have used the example of {1., 1., 1.} to illustrate changing
from the semi-white color of the original plot to a true white that matches
the plot background.  Be sure to use decimal points as above when expressing
color values for your pixels, as something like {1, 1, 1} will not
be understood correctly for this purpose.  If you want to change the
semi-white color of your original plot to black, use {0., 0., 0.}.
The fourth and final line re-establishes the newly altered set of pixel data
as an image object, and displays the altered image.

Hope this helps.
Best Regards,
J. Batista

On Mon, Jul 26, 2010 at 6:37 AM, maria giovanna dainotti <
mariagiovannadainotti at yahoo.it> wrote:

> Dear Mathgroup,
> I have the following function
> R1==1.029
> R2==3.892
> R3==8
> e1==250
> e2==11.8
> e3==80.5
> i==pi/12
> spherenear[x_,y_]:==((R3^2-x^2-y^2)^(1/2))
> spherefar[x_,y_]:==-((R3^2-x^2-y^2)^(1/2))
> emptynear[x_,y_]:==Min[Re[spherenear[x,y]],Re[(R2^2-x^2)^(1/2)+y*Tan[i]]]
> emptyfar[x_,y_]:==Max[Re[spherefar[x,y]],Re[-(R2^2-x^2)^(1/2)]+y*Tan[i]]
> jetnear[x_,y_]:==Min[Re[spherenear[x,y]],Re[(R1^2-x^2)^(1/2)+y*Tan[i]]]
> jetfar[x_,y_]:==Max[Re[spherefar[x,y]],Re[-(R1^2-x^2)^(1/2)]+y*Tan[i]]
>
> f[x_,y_]:==((jetnear[x,y]-jetfar[x,y])*e1+e3*(spherenear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefar[x,y])+e2*(emptynear[x,y]-jetnear[x,y]+jetfar[x,y]-emptyfar[x,y]))*Boole[-R1==EF==82==A3x==EF==82==A3R1]+((emptynear[x,y]-emptyfar[x,y])*e2+e3*(spherenear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefar[x,y]))*(Boole[-R2<x<-R1]+Boole[R2>x>R1])+(spherenear[x,y]-spherefar[x,y])*e3*(Boole[x<-R2]+Boole[x>R2])
>
>
> ContourPlot[f[x,y],{x,-8,8},{y,-8,8},Contours==EF==82==AE{0,100,200,300,400,500,600,700,800,900}]
>
> From the picture you can see there is a white contours that results a bit
> odd, I
> think th at it comes out from the introduction of the Min and Max.
> I would like to remove this white contour. Could you help me?
> Thanks a lot for your attention
> Cheers
> Maria
>
>


  • Prev by Date: Re: Disable save in player pro
  • Next by Date: Re: AxesLabel parallel to 3D axes?
  • Previous by thread: Re: Disable save in player pro
  • Next by thread: Re: Problem with Min Max between two functions