shrx
  • Member for 8 years, 9 months
  • Last seen this week
  • Slovenia
How to ask Mathematica to imitate Andy Warhol's pop-art painting?
30 votes

Alright, instead of separating the picture by graylevels, I tried to get more involved with component detections. I noticed the original painting has a different color for hair, face, mouth, eyes, and ...

View answer
How can Mathematica be used to create images like these?
27 votes

A function to subdivide the triangles based on their gray level: h[{v1_, v2_, v3_}] := With[{a = EuclideanDistance[v1, v2], b = EuclideanDistance[v1, v3], c = EuclideanDistance[v2, v3]}, With[...

View answer
Is there an easy way to use Matteo Niccoli's perceptual color maps for 2D plots in Mathematica?
21 votes

Here's my attempt at recreating the LinearLCM palette. It turned out to be very tricky, because it's not a linear problem. In addition the blog article and the paper cited are confusing the terms "...

View answer
How to make a Cahn–Hilliard model GIF
13 votes

Taken from the Matlab code here http://www.math.utah.edu/~eyre/computing/matlab-intro/ch.txt with slight modifications: m = n = 256; delx = 1/(m - 1); delx2 = delx^2; x = Range[0, 1, delx]; delt = 0....

View answer
Finding a function that fits the shape of an image
13 votes

I was stuck for a while with a not really acceptable result, but then @belisarius posted his answer and I was able to refine my code with the usage of his findCurvedPath2 function. So I am able to ...

View answer
Remove object from the image
12 votes

This is a fast and quite good way to create the mask of the spider: i = Import["http://i.stack.imgur.com/2Lz0A.jpg"]; mask = Dilation[ DeleteSmallComponents@ ColorNegate@ DeleteSmallComponents@ ...

View answer
Visualization of Bivariate Distributions
12 votes

First you determine the binormal distribution of the data: data = RandomVariate[BinormalDistribution[{1, 0}, {2.5, 5}, 0], 10^4]; dataX = data[[All, 1]]; dataY = data[[All, 2]]; dist = ...

View answer
Discrete ColorData scheme with n colors?
Accepted answer
11 votes

Function to generate n equally-spaced colors: discreteColors[n_] := With[{partL = Ceiling[Sqrt[n]]}, DeleteCases[ Flatten[Transpose[ Partition[ Table[Lighter[Darker[Hue[c], .1], ....

View answer
Creating a colour variation effect of the Northern Lights
Accepted answer
10 votes

First, we define a suitable color function that cycles from green to purple: cf[h_] := If[h < .5, h + .4, (1 - h) + .4] SetAttributes[cf, Listable] And then we apply it to the hue channel of our ...

View answer
Animation of double pendulum
10 votes

This is not a direct answer to your problem, but rather a generalization of @Jens' code from double to n-tuple pendulums. Meaning you can also use it for double pendulums if you like. I'm providing it ...

View answer
How can Mathematica convert CMYK values to RGB or HSB?
Accepted answer
10 votes

rgb = ColorConvert[#, "CMYK" -> "RGB"] & /@ CMYKColor @@@ cmyk ImageAssemble[{Graphics[#, ImageSize -> 20] & /@ Partition[Riffle[rgb, Rectangle[], {2, -1, 2}], 2]}] Edit: to get raw ...

View answer
How to resample a list of Images
Accepted answer
9 votes

You can use ImageResize to resample the z-direction for your purpose. imgs = Import /@ { "http://i.stack.imgur.com/CXvgm.jpg", "http://i.stack.imgur.com/RJJnL.jpg", "http://i.stack....

View answer
How to create effect like Van Gogh's stroke brush?
9 votes

I see the "Van Gogh" style as a combination of brush strokes and an averaging filter. This is the best result of my effort to simulate this style. I'm sure someone with better knowledge can improve it....

View answer
Coloring a shape according to a function
Accepted answer
9 votes

u[x_, y_] := Sin[x] + Cos[y] v[x_, y_] := E^-x + y w[x_, y_] := Tanh[x] + Sqrt[y] RegionPlot[2 x^2 + y^2 < 1, {x, -1, 1}, {y, -1, 1}, Mesh -> None, ColorFunction -> Function[{x, y}, RGBColor[...

View answer
Drawing a ladder graph with Line and Table/Array
8 votes

n = 10; GridGraph[{n + 2, 2}, EdgeStyle -> {1 <-> n + 3 -> Opacity[0], n + 2 <-> 2 n + 4 -> Opacity[0]}, BaseStyle -> Black, VertexShape -> {1 -> Null, n + 2 ->...

View answer
How to use Mathematica to turn a picture into low poly style?
8 votes

i = ExampleData[{"TestImage", "Mandrill"}]; id = ImageDimensions[i]; Create some keypoints and use them to make a triangular mesh: xy = ImageKeypoints[i, MaxFeatures -> 50]; m = VoronoiMesh[xy, {...

View answer
Mapping data on Archimedes' spiral
Accepted answer
8 votes

Using @b.gatessucks' hint, I solved it with the following transformation: max = Max[data]; Show[ ListPlot[{Sqrt[max #[[2]]] Sin[Sqrt[max #[[1]]]], Sqrt[max #[[2]]] Cos[Sqrt[max #[[1]]]...

View answer
When running Mathematica from a Linux terminal, how can I prevent a script from terminating upon logout?
Accepted answer
8 votes

Another option would be to use the at command to create detached jobs: echo "math -script test.txt" | at now

View answer
Wolfram language from batch or py
Accepted answer
8 votes

Here is a minimal example on how to run a mathematica script on a raspberry pi. Create a simple script (I used my bash terminal to do it): echo "sum=1+1; Print[sum]" > test.wl Excecute the script:...

View answer
Log transformation (in dimensions) of an image
Accepted answer
7 votes

You can achieve the desired transformation with the ImageForwardTransformation function. The transformation effect is easily visible on a grid image: grid = Rasterize[ Graphics[Rectangle[], ...

View answer
Reproducing the xkcd "Self-Description" comic
6 votes

A quick example how to generate the first two frames. Just the basic layout, no fancy annotations, but you should get the idea. First, define the functions that draw the frames: frame1[{int1_, int2_}...

View answer
Anti-aliasing not working in Mathematica 10 and Linux
6 votes

I had to modify the /usr/local/bin/mathematica script to fix 3D antialiasing. It seems that the GLTest script fails and as a consequence Mathematica disables advanced 3D rendering. The fix is to ...

View answer
How to fit multiple Gaussian peaks to data
6 votes

Your provided data is very noisy. You can get more information from it if you filter it first. I will apply a LowpassFilter and a logarithmic transform on the $y$ values, and scale down the $x$ values....

View answer
To put a plot inside of a plot
Accepted answer
6 votes

Take a look at Inset: Plot[Exp[-x], {x, 0, 10}, PlotRange -> All, Epilog -> Inset[Plot[Sin[x], {x, 0, 2 π}], Scaled[{.7, .5}]]]

View answer
Volumetric Rendering of cylinder symmetric radial image
Accepted answer
6 votes

Here is my solution using RevolutionPlot3D to draw the disk layers, it's faster; First convert the image to data rows: imgd = Map[First[#] &, ImageData[ColorConvert[img, "Grayscale"]], {2}]; ...

View answer
Derive a smooth circle with cusp from an image
6 votes

Cusp detection using information from this post, and following the code from @belisarius' answer: Transformation of the image to polar coordinates: maxRadius = r + 10; polar = ImageTransformation[i1,...

View answer
Faking MoleculePlot for compounds where it isn't available
5 votes

If you have OpenBabel installed, you can use its built-in structure optimization methods to generate 3D structures from SMILES structure format provided by Mathematica: Import["!obabel -:\"" <> ...

View answer
How to use Rescale to make a brighter image?
Accepted answer
5 votes

First, convert your data arrays to images with Image[]. If your imageR and imageG have good brightness, and imageB is too dark: meanIntensity = Mean[ImageMeasurements[#, "MeanIntensity"]& /@ {...

View answer
How to find alignments of interlocking shapes?
5 votes

A different approach: The goal is to minimize the combined region's boundary length while keeping the area maximized. We define the two initial regions f = LaminaData["Salinon", "Region"]; r1 = ...

View answer
Anti-aliasing not working in Mathematica 10.3 and XUbuntu
5 votes

Cross-posted from the related issue, this is the workaround that I found: I had to modify the /usr/local/bin/mathematica script to fix 3D antialiasing. It seems that the GLTest script fails and as a ...

View answer