# Tag Info

## Hot answers tagged image

57

PLEASE NOTE There is a reason why watermarks are there in the first place - to prevent unauthorised reuse of images. For more information on the issues around removing watermarks from images, this Wikimedia article is just one of many useful resources. The answer below is intended as an exercise in automatically removing text from an image ...

54

An extended comment follows. Mondrian, in the late work referenced by the OP and characterized by primary colored rectangles separated by black lines, employed 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. ...

44

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

44

TUTORIAL Import Image img = Import["https://i.stack.imgur.com/xzcUg.jpg"] Split into Components Using this approach (credit: nikie): m = MorphologicalComponents[Binarize@ColorNegate[ColorConvert[img, "Grayscale"]]]; Colorize[m] components = ComponentMeasurements[{m, img}, {"Area", "BoundingBox"}, #1 > 100 &]; trim = ImageTrim[img, #] & /@ ...

39

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

32

As was correctly noted in comments, out-of-focus images cannot been correctly detected by a simple gradient filter since out-of-focus images can have sharp edges. I propose another simple idea to detect such images. Introduction Roughly speaking, the brightness of a defocused image $B(x,y)$ is a convolution of a focused image $B_0(x',y')$ with some kernel \$...

32

Without claiming much generality, I made the following. I'm using a slightly more complex image than your proposed one. i = Binarize@Import@"http://i.stack.imgur.com/qDby8.png"; idi = ImageDimensions@i; vertexI = SelectComponents[i, "Count", 5 < # < 100 &]; disk = 20 (*use some heuristics to ensure a ...

32

This version of generation code is originally posted at wolfram community. I guess a story-telling type post would attract more upvotes and probably give some insight about how to 'solve problems' using Mathematica, so I would go into details and try to explain not only the code but also how I figured out how to write them. How this works? In fact, this ...

32

Another starting point, where the objects being more or less fixed size disks is used ad hoc to measure their centroids as components after some mangling, and those which are close enough to each other are connected in the graph if out of sample of four hundred points along the edge at most four are not "white." Image is in the variable img and plenty of ...

30

I think the essence of the problem here is that width needs to be counted orthogonally to some best fit line going through the elongated shape. Even naked eye would estimate some non-zero slope. We need to make line completely horizontal on average. We could use ImageLines (see this compact example) but I suggest optimization approach. Import image: i = ...

29

Update 2: The function projectToWalls does not work in version 12.0 because the function PlotRange no longer works. To fix the issue, replace PlotRange with plotRange where plotRange = PlotRange/.AbsoluteOptions[#, PlotRange] &; in the definition of projectToWalls. Original answer: You can post-process a Graphics3D object to project the lines to the ...

28

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

24

One simple way of "filtering" your data is to treat the points as a graph, and search for the shortest path from left to right: xScale = 10.; xy = Transpose[{N[Range[Length[data]]]*(xScale/Length[data]), data}]; start = {-xScale, Mean[data]}; finish = {2*xScale, Mean[data]}; graph = NearestNeighborGraph[Join[{start}, xy, {finish}], 25]; graph = ...

24

No, they are not copyright-free, but the data they are based on is openly licensed. The map data mainly comes from OpenStreetMaps (which is licensed under the Open Database License, similar to Creative Commons) and so you will need to include OpenStreetMaps Contributors in your attribution. If you hover over a GeoGraphics, you can see Wolfram's attribution ...

23

Tricky. But with a bit of creative cheating, I can get close: First, load the image and binarize it: img = Import["http://i.imgur.com/qAZBdFb.jpg"]; bin = MorphologicalBinarize[ColorNegate@img, {.1, .5}] I invert the image for two reasons: First, MorphologicalBinarize takes a lower and an upper threshold, i.e. it assumes bright blobs on dark ...

22

A few minor mistakes: corners and the target coordinates weren't in the same order For some reasons, pixels isn't the default unit for ImagePerspectiveTransformation and friends - you have to specify PlotRange and DataRange explicitly the target coordinates should go first in FindGeometricTransform - alternatively, you can pass InverseFunction@ft[[2]] to ...

22

Reading the file as Import["file.jpeg", "ImageNoExif"] is noticeably faster on my machine than the default Import["file.jpeg", "Image"] Benchmark in 11.1: Import["~/Desktop/Untitled.jpg", "Image"]; // RepeatedTiming (* {0.054, Null} *) Import["~/Desktop/Untitled.jpg", "ImageNoExif"]; // RepeatedTiming (* {0.025, Null} *) This is not a full solution, ...

21

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

21

i = Binarize@Import["http://i.stack.imgur.com/qofeF.png"]; vertexI = SelectComponents[i, "Count", 10 < # < 100 &]; vxPos = ComponentMeasurements[vertexI, "Centroid"]; lines = Subsets[Range@Length@vxPos, {2}]; linePos = lines /. vxPos; ti@x_ := Total@Flatten@ImageData@Binarize@x p = Position[ti@i - ti@Show[i, Graphics@Line@#] & /@ ...

20

Load image img = Import["http://i.stack.imgur.com/qzMGE.jpg"] ImagePartition and DominantColors Make an array of Disk of the DominantColors in each part of ImagePartition. Rotate[ Graphics@MapIndexed[ {First@DominantColors[#1, 1], Disk[#2, 1/2]} & , ImagePartition[img, 10], {2} ] , -π/2] ImageResize and ImageData But I find the solution ...

19

Let's start with an example set everyone (at least everyone with a recent Mathematica version) should be able to use: frames = Image /@ ExampleData[{"TestAnimation", "ToyVehicles"}][[1, 1, All, 2]] Start with an interesting point and follow that. To get a point, just select an image, press . and select your point and copy its coordinates using ctrl+c. In ...

19

One can use Prolog to create a background for a Plot. Plot[Sin[x], {x, 0, 2 Pi}, PlotStyle -> Red, Prolog -> Inset[RandomImage[UniformDistribution[{.2, .6}], ColorSpace -> "Grayscale", ImageSize -> Full]], PlotRangeClipping -> False, AxesStyle -> White]

18

Taking the Fourier transform is easy and fun! Let's strip away some of the complexities. First, remove the color from the image, since this just complicates things (you can always take the transform of each color channel separately). img = ColorConvert[Import["ExampleData/lena.tif"], "Grayscale"]; Here are the magnitude and phase of the Fourier transform: ...

18

Update Silvia proposed a much faster algorithm that I believe produces I uniform distribution. Here is my implementation of it. pointsInMask2[mask_Image, n_Integer, range : {_, _} : {0, 1/2}] := Reverse @ ImageData @ Binarize[mask, range]\[Transpose] // SparseArray[#]["NonzeroPositions"] & // RandomChoice[#, n] + RandomReal[{-1, 0}, {n, 2}] ...

18

The answer by Vitaliy is great but his approach has one drawback: ImageRotate introduces artifacts depending on the Resampling method which affects the final estimates for the slit width. A better solution would process the original image data without distorting it. The following approach does not include any artificial manipulations with the original data ...

18

Doing this with basic image processing can be done. In comparison to the post you have linked, your situation is more complicated because you have a monochrome image with no option to separate colors. Additionally, your graph is surrounded by a frame. Let's assume we want to separate not the line but the area under or over the line that is inside the frame. ...

17

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

17

Here's an idea that could work: The "Ferrite" areas have a border that's slightly darker than the background, while the area in between has a border that's slightly brighter than its neighborhood. So a filter that compares each pixel with the average brightness in the neighborhood, like an LoG filter should be a good start: img = Import["http://i.stack....

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