# Tag Info

40

Needs["PolyhedronOperations`"] poly = Geodesate[PolyhedronData["Dodecahedron", "Faces"], 4]; amplitude = 0.15; twist = 4; verts = poly[[1]]; faces = poly[[2]]; phases = RandomReal[2 Pi, Length[verts]]; newverts[t_] := MapIndexed[{Sequence @@ (RotationMatrix[twist Last[#1]].Most[#1]), Last[#1]} (1 + amplitude Sin[t + phases[[First@#2]]]) &, ...

37

The following method doesn't require parameters and discovers also oblique views. obl[transit_Image] := (SelectComponents[ MorphologicalComponents[ DeleteSmallComponents@ChanVeseBinarize[#, "TargetColor" -> Red], Method -> "ConvexHull"], {"Count", "SemiAxes"}, Abs[Times @@ #2 Pi - #1] < #1/100 &]) & @ transit; ...

36

An extended comment follows. Mondrian, in the late work referenced by the OP and characterized by primary colored rectangles separated by black lines, employes an extraordinarily sophisticated understanding of perception, color, and light. As background to understand what Mondrian does, I recommend The Interaction on Color, by Joseph Albers and Alfred C. ...

30

Basically, you want to fit a shape to a set of points with outliers. One common algorithm to do this is RANSAC (random sample consensus). The basic outline of this algorithm is: Select N points at random (where N is the minimum number of points required for fitting the shape, i.e. 2 for a line, 3 for a circle and so on) Fit the shape to these points Repeat ...

29

Obtain the image: i = Import["http://i.stack.imgur.com/iab6u.png"]; Compute the distance transform: k = DistanceTransform[ColorNegate[i]] // ImageAdjust; ReliefPlot[Reverse@ImageData[k]] (* To illustrate *) Identify the "peaks," which must bound the Voronoi cells: l = ColorNegate[Binarize[ColorNegate[LaplacianGaussianFilter[k, 2] // ImageAdjust]]]; ...

27

Here is my attempt to be Piet Mondrian colors = {RGBColor[0.9, 0.9, 0.9], RGBColor[0.05, 0.05, 0.05], RGBColor[0.8, 0.1, 0.1], RGBColor[0.1, 0.1, 0.5], RGBColor[0.9, 0.7, 0.1]}; split = # /. d : Rectangle[{x1_, y1_}, {x2_, y2_}] :> With[{t = RandomReal@BetaDistribution[10, 10], r = Random[]}, Which[ r < 0.3 (x2 - x1)/(y2 - y1), ...

27

This is a similar idea to ybeltukov's, iteratively splitting rectangles into two smaller rectangles. I've used an integer grid to avoid getting small offsets between adjacent blocks, and a weighted random choice to decide whether to split horizontally or vertically or do nothing. The idea is that long thin rectangles should preferentially be split along the ...

25

==== Method 1 === Here is a way to get a graph from an image. MorphologicalGraph can get you started. img = Import["http://i.stack.imgur.com/9HXZ5.png"]; g = MorphologicalGraph[img] And here is your KirchhoffMatrix of the graph. Please note that MatrixPlot averages values for the best visual representation, - actual plot would be too detailed to be a ...

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] ]; ...

22

i = Import@"http://i.stack.imgur.com/8I3B1.jpg"; f[{{tmin_, tmax_}, {rmin_, rmax_}}, ___] := Module[{l = Join[{{0, 0}}, Table[{Cos@t, Sin@t}, {t, tmin, tmax, (tmax-tmin)/100}]]}, {Texture[i], EdgeForm[], Polygon[l, VertexTextureCoordinates -> 1/2 Transpose[Transpose[l] + {1, 1}]]}] Framed@PieChart[{1, 2, 3, 4, 5, 6}, ChartElementFunction -> f] ...

21

One standard way to detect circular shapes is to binarize the image and apply a distance transform: The maxima locations of the distance transform are the centers of the circles. To make this work on your ellipses, I first have to stretch them to be (roughly) circular, as @Rahul Narain suggested in a comment: img = ...

19

Here a quick hack for PNG images. As its Wikipedia page shows the format works with coded chunks and you can make up and insert chunk types yourself. I'm not sure how safe it is to add beyond the official end of file marker as Simon Woods suggests in his answer. It seems like a breach of the standard to me. The following code, which more closely seems to ...

19

lin[cam_, obj_][t_] := cam t + (1 - t) obj s[cam_, obj_] := First@Solve[lin[cam, obj][t][[3]] == 0, t]; tr[cam_, obj_] := lin[cam, obj][t] /. s[cam, obj] // FullSimplify And that's it: tr[ ] i your transformation function. Let's test it with a Rubik's cube, simulating the video you linked. The following boring part is building the cube. We will make only ...

18

When thinking about graphics formats that can be displayed in web browsers and also in Word, the first thing that comes to mind is a rasterized image. However, there is one alternative that makes including comments a complete no-brainer: SVG (scalable vector graphics). The way you do it is similar to what cormullion suggested for EPS, except that EPS of ...

18

Preload all chemical data: ChemicalData[All, "Preload"]; RebuildPacletData[]; (* the latter should not really be necessary *) Get all names: cd = ChemicalData[]; Get their molecular formulae: l = ChemicalData[#, "MolecularFormulaString"] & /@ cd; By counting the Cs, Os and Hs in the tattooed diagram we know we have to find ...

17

This is more of an add-on to Vitaliy's excellent answer, than a completely new approach. I wanted to try to simulate some of the image distortion that would be seen at the jar walls. A simple (though utterly wrong in a physics sense) way to do this is to make the demagnification vary according to the jar image intensity. Load a picture and the jar image, ...

17

================= UPDATE ====================== Due to @halirutan comment I'll add a note on realism. First of all pure water and clouds are not the best subject to simulate reflecations because they have fractal structure - meaning they tend to appear the same on different magnification scales. So it is hard to give impression to a human eye of refraction ...

17

On my system (Windows 7 64-bit, 12GB, Mathematica v8) I only see a factor of 2 between the image file size and the memory used by the image data. This agrees with the observation that packed arrays of integers use 32 bits per element. To confirm this, a ConstantArray containing values of $2^{31}-1$ (the maximum signed 32-bit integer) is packed and has a ...

17

Here's a method based on creating a MeshRegion from the text: text = Style[HoldForm @ Sum[x^2, {x, 0, 10}], 100, Bold]; graphics = First[text ~ExportString~ "PDF" ~ImportString~ "PDF"]; region = DiscretizeGraphics[graphics, MaxCellMeasure -> 5]; image = ExampleData[{"ColorTexture", "Kingwood"}]; RegionPlot[region, Frame -> False, ...

17

image = Import["http://i.stack.imgur.com/UNXEV.jpg"]; n = TotalVariationFilter[image, 0.05] b = LocalAdaptiveBinarize[n, 50] s = DeleteSmallComponents[ColorNegate[DeleteSmallComponents[b, 20^2]], 20^2] (d = DistanceTransform[s]) // ImageAdjust m = MaxDetect[d, 10] (w = WatershedComponents[ColorNegate[d], m]) // Colorize c = ComponentMeasurements[w, ...

16

Here's a reorganization of GaussianRandomField[] that works for any valid dimension, without the use of casework: GaussianRandomField[size : (_Integer?Positive) : 256, dim : (_Integer?Positive) : 2, Pk_: Function[k, k^-3]] := Module[{Pkn, fftIndgen, noise, amplitude, s2}, Pkn = Compile[{{vec, _Real, 1}}, With[{nrm = Norm[vec]}, ...

16

I believe this is a bug in Mathematica. It can be verified that the unreasonable memory usage is due to array unpacking by On["Packing"] ExportString[Image@RandomReal[1, {30, 30}], "BMP"]; So please report it to support@wolfram.com so this can be fixed for the benefit of all of us, and point them to this discussion. Some further playing with Simon ...

16

Circular Hough Transform I have had fun implementing a circular Hough transform based solution for this question (in part using some MMA9 Image3D functionality which has become available in between). By this shape-related approach we can overcome the color restrictions of the approaches tried so far. The method starts with an edge detection, followed by a ...

15

There is something you can do. I just tried it with a JPEG image that I pasted into a notebook. The original image had 900kB and the notebook with only that image had 11.2 MB! Let's say you have an image in an output cell of your notebook, then select the cell bracket, go to Cell > Convert To... > Bitmap and the resulting notebook will be much ...

15

Basically, you import the image: i = Import["http://upload.wikimedia.org/wikipedia/commons/2/2c/Crow_on_the_sign_of_no_parking.jpg"] Tidy it up: mb = MorphologicalBinarize[i] Isolate the areas of interest: cn = ColorNegate[Closing [mb, 10]] Use component analysis: sc = SelectComponents[ cn, {"Eccentricity", "Circularity"}, #1 < .5 ...

15

Your problem is essentially colour quantization, and to make it look good you need some form of dithering. Floyd-Steinberg dithering is a classic algorithm that also happens to have nice pseudocode in the Wikipedia article. (Rojo's answer appears to do something like random dithering.) Note: This functionality probably exists somewhere inside Mathematica ...

15

Played with some image processing functions, get some rough procedure. Import the test image: img = Import["http://i.stack.imgur.com/H2Ksg.jpg"]; Do some gamma adjust to emphasize the edge: img // ImageAdjust[#, {0, 0, 5}] &; Draw rough edges: GradientFilter[%, 2, "NonMaxSuppression" -> True] // ImageAdjust Binarize and dilate it to form ...

15

First, there is no need to use Module in your sample code above. You could write simply: CCGray[pic_?ImageQ] := ColorConvert[pic,"GrayScale"] Now, if you want to manage the channel mixing manually you can use ImageApply and Dot: customGray[img_?ImageQ, ker_?VectorQ] := ImageApply[ker.# &, img] img = Import["http://i.stack.imgur.com/wtlqF.jpg"]; ...

15

Here's a way to approach fingertip removal using some of the morphological operations: img = Import["http://i.stack.imgur.com/oY9cp.jpg"]; blurImg = ImageAdjust[ImageConvolve[img, ConstantArray[0.01, {100, 100}]]]; bw = Erosion[MorphologicalBinarize[blurImg, 0.67], 50]; boundBox = MorphologicalComponents[bw, Method -> "BoundingBox"]; mask = ...

15

Here's my go: pic = Import["http://www.agrisera.com/dokument/bibliotek/sample_quality1.jpg"]; Framed[pic] Isolate the picture by deleting rows and columns with mostly white, and reorient for convenience. pic2 = pic // ImageData // {#, Transpose@#} & // Count[#, {1., 1., 1.}]/Length[#] & /@ # & /@ # & // Flatten[Position[#, n_ /; n < ...

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