Tag Info

Hot answers tagged

59

TL;DR: package at the bottom of post. UPDATES 6: Tiny update: Import can now use the ".bvh" extension to determine the import type. The code that does this is ugly, but I don't see any other way at the moment. out = Import["C:\\Female1_C03_Run.bvh"] 5: Added error checking and registered the package as an official importer for "BVH" files, so ...


38

Amusingly enough, the images above actually arose as an accidental by-product of browsing inane YouTube conspiracy theory videos. I happened across a rather beautiful video of a "mirror cube" device produced by a man in Germany named Ben Palmer, who apparently produced it in an attempt to bring recognition to a philosopher named Walter Russell (the first ...


31

EDIT: I found a version of the source image with fewer jpeg artifacts. My idea would be to extract pixels along the border of the shadow, inside and outside of the shadow. Then I have a list of pairs of RGB values, and I can find a suitable transformation from "shadowed" pixels to "non-shadowed" pixels. But first, I must find the shadow area. I would ...


31

First, define the dimensions and colors associated with our matrix: {mheight, mwidth} = mdim = {12, 20}; mdepth = 20; mcolors = Reverse@Array[ Blend[{{0, Darker[Green, 0.9]}, {0.4, Darker[Green]}, {0.6, Darker[Green]}, {0.90, Lighter[Green]}, {1, Lighter[Green, 0.8]}}, #/(mdepth - 1)] &, mdepth, 0]; Next, define some useful ...


30

Edit Here is a different approach using Graphics to actually draw some brush strokes. I run a GradientOrientationFilter on a smaller version of the image to estimate the local image gradient, and use that information to create a collection of randomly shaded lines: img = Import["http://i.stack.imgur.com/XwYg7.jpg"]; im = img ~ImageResize~ 200 ...


23

Forward Mapping One way to do it is to create the texture for one tile and then transform repeated copies of it in a way that resembles the original illusion. First we create the tile: tile = Module[{KeyHole}, KeyHole[base_] := Sequence[ Disk[{0, 1/3} + base, 1/10], Rectangle[{-1/30, 1/15} + base, {1/30, 1/3} + base] ]; ...


18

Edit Old answer follows below The features of your new set are very different from the first image. For example: There are components "touching" the borders. They have "hidden" structures like this: So it needs a different approach: l = {"http://i.stack.imgur.com/OZEvk.png", "http://i.stack.imgur.com/Tl1Pm.png", ...


16

The kite-domino tiling is based the pinwheel tiling which is falls out of a particular decomposition of a right triangle with legs of length 1 and 2. In the code that follows, rt[{a,b,c}] represents such a right triangle and dissect indicates how such a triangle should be decomposed into smaller copies of itself. We simply iterate the dissect function on ...


15

You could start to scrape allowed characters in that font, e.g.: mcolors = Blend[{{0.00, Darker[Green, 0.7]}, {0.90, Darker@Green}, {0.90, Lighter[Green]}, {1.00, Lighter[Green, 0.9]}}, #] &; $unic := $unic = Join[{"\[Wolf]", "\[MathematicaIcon]", "\[HappySmiley]"}, Drop[ToExpression[ "\"" <> StringReplace[#, "U+" -> ...


15

A simple numerical maximization using NMaximize as suggested by b.gatessucks: pts = Array[{x[#], y[#]} &, 10]; mindist2 = Min[#.# & /@ Subtract @@@ Subsets[pts, {2}]]; vars = Flatten[pts]; constraints = Thread[0 <= vars <= 1]; {md2, rules} = NMaximize[{mindist2, constraints}, vars]; minimaldistance = Sqrt[md2] (* 0.381759 *) ...


13

Edit: Shorter ImageTrim version as pointed out by Matthias Odisio Use MorphologicalComponents and utilize ComponentMeasures to extract the "BoundingBox" which is already the row- and column-number you can then feed directly to ImageTake or even better to ImageTrim. ImageTrim has the big advantage that it can handle the bounding box coordinates directly: ...


12

This is a difficult problem, as the referenced literature in the linked SE questions may attest. I can provide some steps towards your goal, but I don't have the full answer. im = ImageTake[Import["http://i.stack.imgur.com/rSOow.png"], {10, -10}, {10, 220}] First, trying to find the shadow mask, ChanVeseBinarize seems to work best here. Note that I ...


12

Your functions take two arguments as input. Yet they return one argument as output. So the output of f cannot serve as the input of g and vice versa. You can't compose the functions with until the outputs of one function can serve as the input for the other function. Reduce your arguments in f, g by placing them in a list. This appears to work: f[{x_, y_}] ...


12

I got my CIE color matching functions from here. These are the CIE 1931 2-deg, XYZ CMFs modified by Judd (1951) and Vos (1978). {λ, x, y, z} = Import["http://www.cvrl.org/database/data/cmfs/ciexyzjv.csv"]\[Transpose]; ListLinePlot[{{λ, x}\[Transpose], {λ,y}\[Transpose], {λ, z}\[Transpose]}, PlotLegends -> {"X", "Y", "Z"}] Conversion of color ...


11

The two standard methods are SlotSequence, and the "injector pattern." Related question on StackOverflow: How to Block Symbols without evaluating them? SlotSequence ClearAll[myBlock] SetAttributes[myBlock, HoldAll] varList = {"a", "b", "c", "d"}; myBlock[args_] := Function[Null, Block[{##}, args], HoldAll] @@ (MapIndexed[Set, Join @@ ...


11

One major improvement to any matching algorithm in this specific case will be to get rid of the diacritical marks in the first list that don't appear in the second list. I'm not aware of any Mathematica function to do that and too lazy to roll a conversion table myself, but there is a simple Java routine to be found here that does this. I slightly modified ...


11

Supporting the maxim "there is always another way to do it": list = {"M","a","t","h","e","m","a","t","i","c","a"}; StringJoin accepts lists directly, and in fact is faster this way: StringJoin @ list "Mathematica" Also, StringJoin has the short form <> therefore you could also use: "" <> list "Mathematica" Speed check: large = ...


11

Since this does seem to be a kind of packing problem I searched for prior explorations, and found a list of packings for equal-circles within a square at: http://hydra.nat.uni-magdeburg.de/packing/csq/d1.html The best known packing for N = 10 is shown as: The coordinates for the points are: 1 -0.055497063038156969690135505676 ...


11

Definition GaussCurvature[f_] := With[{dfu = D[f, u], dfv = D[f, v]}, Simplify[(Det[{D[dfu, u], dfu, dfv}] Det[{D[dfv, v], dfu, dfv}] - Det[{D[f, u, v], dfu, dfv}]^2) / (dfu.dfu dfv.dfv - (dfu.dfv)^2)^2]]; Sphere As @ ubpdqn already remarked GaussCurvature[{Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]}] 1 Ellipsoid ellipsoid = {2 Cos[u] ...


10

This one is very close to your Python code Join @@ Table[Append[a, i], {a, A}, {i, Intersection[Range[3], a]}] {{1, 2, 3, 1}, {1, 2, 3, 2}, {1, 2, 3, 3}, {2, 3, 4, 2}, {2, 3, 4, 3}, {3, 4, 5, 3}}


10

Mathematica has a few very limited 'effects' built-in: i = Import["http://i.stack.imgur.com/XwYg7.jpg"]; oil = ImageEffect[i, {"OilPainting", 4}] boss = ImageEffect[i, {"Embossing", 15}] Combining them: ImageAdjust[ImageCompose[boss, {oil, .5}], {1, 0}] But for the best effects, you'll have to start drinking absinthe...


10

You can achieve an effect like this by using CurvatureFlowFilter and GaborFilter. The effects are best viewed in full resolution. Here is the original image: img = Import["http://i.stack.imgur.com/XwYg7.jpg"] Now we smooth is nicely with the CurvatureFlowFilter: imgsmooth = CurvatureFlowFilter[img, 2] And generate a gradient image of the original ...


10

The following answer is based on the assumption that you made a mistake in your opening post and that the term f[2] = 2 a b (1 + 6 a) is actually supposed to be f[2] = 2 a b (1 + 3 a), i.e. with a 3 replacing the 6. Let's first concentrate on the coefficients. Later we can easily construct the polynomials from them. The following image illustrates the ...


9

Use StringJoin: StringJoin @@ {"M", "a", "t", "h", "e", "m", "a", "t", "i", "c", "a"} "Mathematica"


9

There are two aspects of this question that distinguish it from previous questions: The request for a general template, as opposed to just a single example. The fact that the given example is a polynomial of degree three, whereas as opposed to the quadratic examples which appear in many places, including Stan's book. To deal with the first issue, in ...


8

An alternative {FromDigits@{##} , ##} & @@@ Tuples@Range@{4, 3}


8

If you create a table like: Table[{10i + j, i, j}, {i, 1, 4}, {j, 1, 3}] that nearly gives you what you want, but you'll notice they are grouped together, but that can be sorted by simply flattening that result appropriately Flatten[Table[{10i + j, i, j}, {i, 1, 4}, {j, 1, 3}], 1]


8

There is one way to produce the expected result with Table pointed out by ssch in the comments, here are another ones, with Array : Array[{10 #1 + #2, #1, #2} &, {4, 3}] // Flatten[#, 1] & or with a powerful function like Outer : Outer[{10 #1 + #2, #1, #2} &, Range[4], Range[3]] // Flatten[#, 1] & {{11, 1, 1}, {12, 1, 2}, {13, 1, 3}, ...


8

Nearest automatically uses EditDistance by default: l1 = {"Refresco em Pó TANG de Pêssego 30g", "Refresco em Pó CLIGHT de Maracujá 9g", "Refrigerante ANTARCTICA Soda Limão Garrafa 600ml", "Refresco em Pó CLIGHT de Abacaxi com Hortelã 8g", "Refrigerante ANTARCTICA Guaraná Lata 350ml", "Refresco em Pó CLIGHT de Lima Limão 9g", ...


8

Just for something different Fold works too: Fold[#1 <> #2 &, "", {"M", "a", "t", "h", "e", "m", "a", "t", "i", "c", "a"}] "Mathematica"



Only top voted, non community-wiki answers of a minimum length are eligible