Hot answers tagged

14

I'm not 100% sure what you want. Loosely speaking, your images look like there are hills and valleys, with light coming from the left. And I think you're looking for the "valleys" in that landscape. A mathematical model for this would be: There's a "height" (or "depth") for every pixel, and the image you have is the gradient (in X-direction) of that height ...


14

moon = Import[ "https://upload.wikimedia.org/wikipedia/commons/f/f0/Full_Moon_as_\ Seen_From_Denmark.jpg"] Here are two ways to get something like that: with Texture or with ColorFunction Texture: pic = ImageCrop @ ImageResize[ColorConvert[moon, "Grayscale"], Scaled@.3] Worse quality than is possible with this image but I had to make it smaller ...


14

Step 1: find the curve in the black and white image. For this, I will use a shortest path search, and to make sure it finds the path I'm looking for (instead of one of the short cuts through the labels), I will give it a few "path markers" along the way that the path should visit in order: First, load the image, get the black pixels: img = ...


13

Here is an approach based on direct construction of Image3D from ImageData. The basic idea is taken from the subsection "Volume Creation" of the section "Scope" on the Documentation page for Image3D, some other ideas are from the answer by Kuba: moon = Import[ "https://upload.wikimedia.org/wikipedia/commons/f/f0/Full_Moon_as_Seen_From_Denmark.jpg"]; ...


11

I didn't get a good answer, but this is how I would do it and probably how I would evaluate the quality of an answer. Much of what I do below involves manual work, but it could be automated: First, we need some points along the curve. I selected them manually If I hadn't manually selected them, I would have used some image processing including a thinning ...


11

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@ MorphologicalBinarize[i, .25], DiskMatrix[2]] Then, you can use Inpaint with the generated mask: Inpaint[i, mask] You will have to adjust the ...


9

Here's an interactive version -- wherever you point the mouse, the gradient image is shown. Thanks to nikie for the improved mask (using Graphics instead of array manipulations). img = Import["http://i.stack.imgur.com/Na1fq.png"]; dims = ImageDimensions[img]; grad = GradientFilter[img, 2] // ImageAdjust; Manipulate[loc = MousePosition["GraphicsAbsolute", ...


8

I would do this in Mathematica by creating a mask and then applying the filter within that mask. To create a mask, click the image and select "Mask tool in the pop-up dialog". You can then use ImageFilter with the Mask option or you can do the Masking yourself. filtered = ImageAdjust@GradientFilter[originalImage, 4]; ImageCompose[originalImage, ...


7

I don't think you can change the compositing operator but you can dynamically change the appearance. A simple example: im = LinearGradientImage[]; DynamicModule[{pt = {10, 10}}, LocatorPane[Dynamic[pt], im, Appearance -> Graphics[{ Dynamic @ GrayLevel[1 - PixelValue[im, pt]], Disk[]}, ImageSize -> 20]]]


6

There's not much information about what "TextureSynthesis" does in the documentation, but it probably does something roughly like this: Look at the pixels at the border of each inpainting region. Look for nearby similar pixels. Generate a texture based on the pixels found in (2) Let's look at one region in detail: The border of the inpainting mask ...


6

Here is something I tried based on Simon's answer to How to create a new “person curve”? I am starting from a text. pic = Rasterize[Style["Captcha", FontFamily -> "Sans"], ImageSize -> 300] // Image Now introducing Simon functions param[x_, m_, t_] := Module[{f, n = Length[x], nf}, f = Chop[Fourier[x]][[;; Ceiling[Length[x]/2]]]; nf = ...


5

This isn't elegant, but I think it should work pretty reliably. Start with the base plot: plot = ParametricPlot[ Evaluate@BezierFunction[temPoint = RandomReal[{-50, 50}, {5, 2}]][ t], {t, 0, 1}, AxesOrigin -> {0, 0}] Create a version that has the point, but wrap the point in Annotation, with type "Region": plot2 = Show[plot, Epilog -> ...


4

This is kinda slow in my mac so before spending more time on it I rather have some comments from OP. The basic idea is that I want to amplify the gradient on the image and then separate the areas of constant value. img = Import["http://i.stack.imgur.com/LiQsY.jpg"] img2 = Import["http://i.stack.imgur.com/OO36H.jpg"] xx2 = Module[{im = ImageTake[img, ...


3

Here's a quick attempt using morphological image analysis on my own contour plot, since you did not provide yours: Generate a contour plot with some closed contours and style it more or less like yours: contour = ContourPlot[ Sin[2 x]^2 - Cos[2 y]^2, {x, y} ∈ Polygon[CirclePoints[{1, 90 Degree}, 6]], PlotPoints -> 75, Contours -> 4, ...


3

RemoveBackground + HighlightImage seem to work for the provided example. (Though HighlightImage does not seem to support Mouseover, so I insert it after the fact...) knee = Import["http://i.stack.imgur.com/hCC57.jpg"]; mask = Binarize[RemoveBackground[knee], 0]; HighlightImage[knee, mask] /. f_FilledCurve :> Tooltip[Mouseover[{EdgeForm[None], ...


3

The process is quite complicated as you can see. The code creates a set of parametric equation which can give you set of discrete plots. You can choose few of them which might work (At least worked in this case). mess = 1; ParametricPlot[ Evaluate[tocurve[#, 25, t] & /@ lines[[1 ;; mess]]], {t, 0, 1}, Frame -> True, Axes -> False] gives ...


3

Here's one way: dimensiontex = {400, 300}; nobj = 40; distanceobj = 5; greys = RandomReal[{0, 1}, nobj]; rotatemyobj[c_] := Rotate[Graphics[{GrayLevel[c], Disk[{1, 1}, Offset[{10, 4}]]}], RandomReal[{0, 2 Pi}]]; tab = Table[rotatemyobj[greys[[i]]], {i, 1, nobj, distanceobj}, {j, 1, nobj, distanceobj}]; GraphicsGrid[tab] Thanks to Rahul for more concise ...


3

In this case code below works, but it's sensitive to the second parameter of EdgeDetect: Module[{img, poly}, img = Import["http://i.stack.imgur.com/QF8Wk.jpg"]; poly = First@ MeshPrimitives[ ConvexHullMesh[ Cases[RegionIntersection @@@ Subsets[Line /@ ImageLines[EdgeDetect[img, 20], MaxFeatures -> 4], {2}], ...


2

Fortunately this is not so difficult with Mathematica. First, we detect the straight lines, surrounding square with ImageLines: img = Import["http://i.stack.imgur.com/QF8Wk.jpg"]; (* get image *) lines = ImageLines[EdgeDetect[img, 20]][[;; 4]]; (* get lines *) HighlightImage[img, {Green, Line /@ lines}] (* show lines *) First 4 found lines are those ...


2

rowEl[n_, color_] := Rotate[Graphics@{color, Disk[{1, 1}, Offset[{10, 4}]]}, #] & /@ RandomReal[{0, Pi}, n]; GraphicsGrid[ rowEl @@@ Transpose@{ConstantArray[5, 5], RandomChoice[{Black, Gray}, 5]}] Alternatively, if you want to have finer control of distances between, you can avoid GraphicsGrid rowEl2[n_, y_, color_] := ...


2

You should first generate the mask, then you can apply Inpaint. Following is a demo, it can be further enhanced. flt = ColorNegate@MorphologicalBinarize[img, {0.4, 0.9}]; Inpaint[img, flt];


2

According to the documentation Inpaint uses each color seperately, so a colored picture should be easier for Mathematica to process. Especially, since your original colored picture is considerably larger (288 kB) than the grayscale one (120 kB). So, I would say that better results for the former are to be expected. Now, you may use your colored picture and ...


2

Just to save the solution for posterity: As nikie suggested in comments, you are looking for "IntensityCentroid" rather than the simple "Centroid" property to use in ComponentMeasurements. You can find it in the "Details" section of the documentation of the latter function, under "Spatial intensity measurements". In the help description ...


1

I've always wished the moon was more habitable. Starting from the OPs picture: moon = ColorConvert[ Import["https://upload.wikimedia.org/wikipedia/commons/f/f0/Full_\ Moon_as_Seen_From_Denmark.jpg"], "Grayscale"]; ReliefPlot[ImageData[moon], ColorFunction -> "GreenBrownTerrain"]


1

Your image is not still good enough to work on. So I made one and show how to do it. Let say this is your picture XX = (# + RandomReal[{-.1, .1}]) & /@ Range[19]; XX = Join[{0}, XX, {20}]; YY = (# + RandomReal[{-.1, .1}]) & /@ Range[19]; YY = Join[{0}, YY, {20}]; img = ContourPlot[Evaluate[Join[(y == #) & /@ XX, (x == #) & /@ YY]], {x, ...


1

Mathematica also has a builtin function called ImagePeriodogram that returns an Image representing the power spectrum of the image. This won't help with phase spectra or reconstructing images, however.


1

If you drill down the documents' details and options you may find some useful information. Here is my take: EdgeDetect has 2 main parameters pixel range r and t for threshold. The document says the r's default value is 2. For threshold t uses hysteresis thresholding with a global threshold t. For additional forms of the threshold parameter, see the ...



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