In order to avoid "retinal persistence" after the presentation of a stimuli, I need to create a visual noise mask.
This for a screen that has a dimension, in pixel of : 1280 * 960
I believe I could randomly (uniform) assign gray shade to pixels but my attempts yet failed.
Thank you for your attention.
Just noticed:
RandomImage[1, {1280, 960}]
New in Mathematica 8, apparently...
Damn, at last a question on Stack Overflow I could have answered and I was too late... :)
Oh well, here's an alternative solution...
ImageEffect[Image[Table[{0.5, 0.5, 0.5}, {i, 1, 960}, {j, 1, 1280}] ], "GaussianNoise"]
Probably got too many colours in it?
ImageEffect also works on greyscale images.
ImageEffect[Image[Table[0.5, {400}, {600}]], "GaussianNoise"]
Did you try looking in the help docs? One of the first examples for Image should have done it.
Image#RandomReal[1, {960, 1280}]
You can specify a different range of values:
Image#RandomReal[{0.4, 1}, {400, 600}]
Others have already shown you ways of creating a random image. In case you were designing your application to use up the full screen (or based on the current screen's dimensions), you might find it convenient to not hard code the values, but to capture the screen size programmatically. Here's an example showing how:
screenSize = Last /# ("FullScreenArea" /.
Flatten#SystemInformation["Devices", "ScreenInformation"]);
RandomImage[1, screenSize]
Related
I want to solve the following equation. I want to get an expression of x in terms of unknown constants alpha and beta. Does anyone know how to solve this in Matlab or Mathematica?
Thanks.
Here's my one line code in wolfram Mathematica.
'Assuming[alpha>beta>0,Solve[Cos(alpha*Cos(x)) + Cos(beta*Cos(x)) -1.96 ==0,x]] '
Since it doesn't appear simple to get an analytic solution, perhaps a graphic showing the behavior might provide some insight about what to do next.
ListPointPlot3D[Reap[Do[
{alpha, beta, x} = RandomReal[{0, 2 Pi}, 3];
If[alpha > beta,
err = Norm[Cos[alpha*Cos[x]]+Cos[beta*Cos[x]]-1.96];
If[err < .01, Sow[{alpha, beta, x}]]
],{10^6}]][[2, 1]], ViewPoint->{0, -2., 0}]
Once that displays on your monitor you can either adjust the numbers inside that Viewpoint or you might be able to place your mouse inside the graphic, press and hold the left mouse button and drag to rotate the image around.
That graphic seems to show that the solutions lie within a fairly well defined region.
Once you have looked at this then you might bump the range of the random numbers up to {0,4Pi} because it looks like there is more interesting behavior for larger values of alpha and beta.
I made Monte Carlo simulation of a cone shaped light source - like lighthouse. Then I tried to draw results. I took the points from which the rays have come. Then I tried to draw SmoothDensityHistogram, but I have problems with binning. I know that the most rays came from {0,0,0}, but that is just not obvious from the picture. The center is somehow translated, but it should't be.
Here's a link to picture.
Thanks for help.
try to play with the PlotPoints option. Even value of the parameter could help, even though I cannot reproduce your problem:
tb = Table[{RandomVariate[NormalDistribution[0, 3]],
RandomVariate[NormalDistribution[0, 3]]}, {n, 10000}];
SmoothDensityHistogram[tb, PlotPoints -> 6]
everyone
I am currently doing a project in which i am trying to modify a picture of face such that the wrinkles on the face will be removed. Has anyone any clue how to do that? Any algorithm?
Thanks and Best Regards
If you are willing to select the wrinkles "automagically" (using a GUI), you may want to look at inpainting, and also at "Poisson Image Editing", by Perez et al. (http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.133.6932&rep=rep1&type=pdf).
This latter technique is also known as "Gradient blending."
I tried to remove one wrinkle (it is positioned at 7 o'clock) using Poisson editing. Left: Before; Right: After:
The code is in Mathematica, and is too "mispackaged" to be really useful.
As for inpainting, the texture synthesis technique gives this:
Inpaint[eye, w, Method -> "TextureSynthesis"]
I know there are options such as PointSize[Large] or PlotStyle -> Thick, but what if I want to even larger or thicker? Thank you.
PointSize[number] -- size relative to the image
AbsolutePointSize[number] -- absolute size in points
Thickness[number] -- thickness relative to the image
AbsoluteThickness[number] -- absolute thickness in points
Basically the size given by PointSize[0.1] and Thickness[0.1] scale as you resize the graphic. AbsolutePointSize[10] and AbsoluteThickness[10] are always the same size, regardless of the size of the graphic.
(sorry, new user here - is it appropriate to ask a closely related "follow up" question in this manner? If not please advise and I will delete...)
EDIT: moved to a standalone question
EDIT: #Qiang re: obtain the origin information, obtain the plot range information etc. you'll find a lot of what you want from AbsoluteOptions[]
Is it possible that when I Plot a function in Mathematica, it will automatically put near it it's equation(i.e. y = 2x) or even some other text?
At first glance I don't find any option for it, but if there is one I'd like to know.
Thanks
Using Mathematica 6 or higher, I often use Tooltip to help me identify plot curves:
Plot[Tooltip[Sin[x]], {x, 0, 8 Pi}]
Alas, this is only useful when using the graph interactively since you must hover the mouse cursor over the curve. It doesn't work so well on paper or on a static image.
You can use the Epilog option to manually place some text on the plot, as in this example:
Plot[
Sin[x], {x, 0, 8 Pi},
Epilog -> Text["My Text", Offset[{32, 0}, {14, Sin[14]}]]
]
Tweak the arguments of Offset to taste.
This works if you do not mind manual placement. Automatic placement poses some challenges, depending upon the kinds of functions that you wish to plot. But if you know something of the general characteristics of the functions of interest, you could write a function that calculates nice looking values for the Offset arguments. For example, if I knew I was going to plot lots of exponential decline functions, I might define something like the function myPlot in this example:
SetAttributes[myPlot, HoldAll]
myPlot[function_, {var_, min_, max_}] :=
Plot[
function, {var, min, max},
Epilog -> Text[function, Offset[{40, 0}, {var, function} /. var -> min + (max - min)/20]],
PlotRange -> All, AxesOrigin -> {0, 0}
]
... where the arguments to Offset are computed automatically using some arbitrary constants that work reasonably well for these kinds of plots:
Manipulate[
myPlot[1000 E^(-d t), {t, 0, 100}, "My Label"],
{d, 0.01, .2}
]
Since all of these options are programmable, the sky's limit as to how much sophistication you could code up for the label placement. Of course, such programming drifts farther and farther away from the ideal of a built-in option to Plot that just magically drops on some text next to the function. Mathematica 8 or 9 maybe :)
One way to do this, which automatically associates the expression with the style used to plot it, is to use the PlotLegends standard add-on package. The output doesn't look very good by default; I recommend setting the LegendShadow -> None option and using Style on the expressions you stick in the legend to make them look better. Also, loading the package inflicts some funny redefinitions on Plot and related functions which can break some other things if you're not careful.
"Near its equation" is the problem. This isn't an easy problem to solve, and it becomes somewhat impossible when you start getting "busy" graphs with overlapping plots and so on.
I don't have a good example to show, but usually I'll define a "labelling function" that takes the same input as the function being plotted, which places a dot on the graph and writes some text nearby. This has the advantage of being able to easily vary the location of the text but still have it tied to the function.