# Tag Info

36

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]]]) &, ...

33

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

29

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

26

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

24

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

19

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 = ...

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

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

17

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

16

================= 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 ...

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

15

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, ...

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

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

14

The technique is mentioned in one of Wolfram CDF virtual conference talks (See the course: Developing Real-World CDF Applications), as well as being used in a lot of CDF examples (for instance, the slideshow at the beginning of this example) but I will repeat it here, with some improvement. Recompressing images with better compression (Note: While writing ...

14

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

14

Too late and not so general as @Nikie but I will still like to answer in order to highlight a method involving generalized Eigen values! Lets take the image. img = Import["http://i.stack.imgur.com/H63BK.jpg"]; (* Detecting ellipsoidal edges and removing the straight line component *) i = ImageSubtract @@ {EdgeDetect[img, 10],EdgeDetect[img, 10, ...

13

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

13

This is a simple way: Show[ Plot[Sin[x], {x, 0, 2 \[Pi]}], Graphics[{PointSize[Large], Red, Point[{3 \[Pi]/2, -1}], Black, Text["Minimum", {3 \[Pi]/2, -.8}]}]] Edit If you have an image created with Colorize you can apply the same method. In the example below img is the image you obtain by taking the first example given in the Help under ...

12

Using pieces from the linked answers, and Heike's code: Text piece: txt1 = Take[ ExampleData[{"Text", "LoremIpsum"}, "Lines"], {1, -1, 2}][[1]] // StringTake[#, 330] &; Image piece: pic = Import["http://dailytechgadgets.files.wordpress.com/2011/02/old-ferrari.jpg"]; And Heike's code for rectangles: rec[ll_, ur_, pic_] := Module[{crop, ...

12

In Mathematica 8, few image files are supported natively--meaning, without calling external MathLink executables, which results in much faster speed (order of magnitude) and great efficiency in memory usage. Currently only TIFF and JPEG work that way. PNG was close but it was cut-off. What I am saying is that you will see much speed up in the future for PNG ...

12

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]}, ...

12

Mathematica is not really a reference in digital terrain models, and, there are very powerful software packages to deal with geographical information. But... where would be the fun... If the information in the files includes a digital terrain model (DTM), with the surface of the terrain defined by triangular faces (regular or not), then you can easily ...

12

I don't think you can control the interpolation used by Texture. One option might be to embed the image as a Raster primitive instead. Show[ParametricPlot[{20 + 1.4 x - 40 y, x}, {x, 0, 200}, {y, 0, 1}, BoundaryStyle -> Directive[Purple, Thick], PlotRange -> {{0, 201}, {0, 144}}, Prolog -> {Raster @ Reverse @ ImageData @ a}]] Zoomed ...

12

Blend gives smooth transition between a list of colors: cf[v_] := Blend[{Black, Red, Yellow, White}, v] DensityPlot[Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> cf, PlotPoints -> 300] For a clear distinction between some set of contours you can use ContourPlot: ContourPlot[Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> ...

12

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 = ...

12

This problem is essentially because the new-in-9 legending functionality does not produce Graphics objects. It produces something similar to Row (i.e. with an underlying RowBox) that joins the Graphics and the legend. This is a generic object that can be displayed in a notebook but cannot be manipulated as conveniently as Graphics objects. This tends to ...

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