Newest questions tagged graphics image-processing - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-09-22T11:21:57Z https://mathematica.stackexchange.com/feeds/tag?tagnames=graphics+image-processing&sort=newest https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/203517 18 Creating graph out of particles images user929304 https://mathematica.stackexchange.com/users/52181 2019-08-09T12:52:09Z 2019-08-21T19:42:17Z <p>I have recently started learning how to use Mathematica's brilliant image processing tools, and the image I've taken as first example is the following (<a href="https://data.mendeley.com/datasets/352nk3c6sz/2" rel="nofollow noreferrer">source</a>):</p> <p><a href="https://i.stack.imgur.com/rUnvs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rUnvs.jpg" alt="enter image description here"></a></p> <p>So far I've tried to first use <code>LocalAdaptiveBinarize</code> on the image and then use the <code>MorphologicalGraph</code> for the graph mapping but the results appear quite off since the resulting graph has about <span class="math-container">$40000$</span> vertices, whereas we have about <span class="math-container">$310$</span> particles in the image. The ideal mapping would be to map each particle to a vertex (and edges between particles in contact) and study the structure of the configuration as a graph.</p> <pre><code>s2 = MaxDetect@ LocalAdaptiveBinarize[img, 8, PerformanceGoal -&gt; "Quality"] gvertex = MorphologicalGraph[s2, VertexCoordinates -&gt; Automatic] </code></pre> <p>Binarized version:</p> <p><a href="https://i.stack.imgur.com/GAghg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GAghg.png" alt="enter image description here"></a></p> <p>Trying without the Binarization yields somewhat better results but the resulting graph still has little to do with the image. </p> <ul> <li><p>Is there a way to process the image such that the particles can be more accurately detected? In other words, how should one process such <em>particle</em> based images (where typically like here the particles can be assumed to be spheres) in order to detect the particles positions before invoking <code>MorphologicalGraph</code>?</p></li> <li><p>Finally, given we perform the graph mapping, how do assess how close the mapping has been? In other words, other than the basic checks of looking at vertex counts, how can we draw a close comparison between the result and the original image?</p></li> </ul> <hr> <p><strong>Brief update after the wonderful answers:</strong></p> <p>To compare the two resulting graphs that are obtained by both methods of user <a href="https://mathematica.stackexchange.com/a/203540/52181">LukasLang</a> and <a href="https://mathematica.stackexchange.com/a/203688/52181">NikiEstner</a>, the number of assigned vertices (i.e. detected particles) is <span class="math-container">$188$</span> and <span class="math-container">$273$</span> respectively, and the degree distributions are shown below (in same order):</p> <p><a href="https://i.stack.imgur.com/RyvMy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RyvMy.png" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/I588m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I588m.png" alt="enter image description here"></a></p> <p>I reckon these differences arise from the fact that the starting points were different: in the first mentioned answer a binarized version of the original image was used which meant partially information about the depth of the particles in the image was lost. Generally speaking, it is not immediately clear how to assess whether in determining the neighbourhood of a particle, how the particle's position depth (brightness variation, as neatly demonstrated by LukasLang) we see in the image should be taken into account.</p> https://mathematica.stackexchange.com/q/199612 22 How to project 3d image in the planes xy, xz, yz? zeros https://mathematica.stackexchange.com/users/26849 2019-06-02T22:24:12Z 2019-06-03T08:31:17Z <p>Some idea of how to do something similar to the image, but with any 3d object</p> <p><a href="https://i.stack.imgur.com/umd1P.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/umd1P.jpg" alt="Any body in 3d"></a></p> https://mathematica.stackexchange.com/q/199409 2 Plotting large scale image embeddings M.R. https://mathematica.stackexchange.com/users/403 2019-05-30T17:51:57Z 2019-06-29T23:02:20Z <p>I'm looking for help making publication-quality graphics for visualizing 2D embeddings of image datasets, so that they look like this:</p> <p><a href="https://i.stack.imgur.com/V47Wj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V47Wj.png" alt="enter image description here"></a></p> <p>These two-dimensional embeddings of thumbnails (sometimes with magnifying zoom-in's - as shown above in red) are commonly seen plots in ML or computer vision papers, for instance:</p> <ul> <li><a href="https://www.cs.cornell.edu/~kb/publications/SIG15ProductNet.pdf" rel="nofollow noreferrer">Learning visual similarity for product design with convolutional neural networks</a></li> <li><a href="http://www.iri.upc.edu/files/scidoc/1938-Multi-Modal-Embedding-for-Main-Product-Detection-in-Fashion.pdf" rel="nofollow noreferrer">Multi-Modal Embedding for Main Product Detection in Fashion</a></li> <li><a href="https://arxiv.org/abs/1803.09196" rel="nofollow noreferrer">Learning Type-Aware Embeddings for Fashion Compatibility</a></li> </ul> <p><em>This is typically done to show that a neural network learns a function that maps input images to a latent space such that the l2-norm in that space approximated the semantic distance in the input space.</em></p> <p>After learning some latent embedding space and using <code>DimensionReduce</code> (with the <a href="https://lvdmaaten.github.io/tsne/" rel="nofollow noreferrer">TSNE</a> method) you have one (x,y) point for each image, these are then <em>otherwise masaged into a nice disk</em>. I think this is how it's done:</p> <ol> <li>Images are conformed (maybe aspect ratio preserving crops?)</li> <li>The (x,y) points are snapped to some chosen disc-shaped grid (based on step 1) </li> <li>Overlapping photos are somehow dealt with (randomly perhaps or keeping ones with similar entropy)</li> <li>Larger versions of the images are shown for selected areas in rectangular magnifying-glass callouts</li> </ol> <p>Here's another nice example:</p> <p><a href="https://i.stack.imgur.com/kkbon.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kkbon.jpg" alt="enter image description here"></a></p> <p><strong>Example data and code</strong> </p> <p>To get you started, here's the typical input to this problem - a few thousand images and their embedding coordinates:</p> <pre><code>xy = CloudGet @ CloudObject[ "https://www.wolframcloud.com/objects/user-6795023f-6362-45bf-9097-de07f37f89a1/embedding-example-xy"]; thumbs = CloudGet @ CloudObject[ "https://www.wolframcloud.com/objects/user-6795023f-6362-45bf-9097-de07f37f89a1/embedding-example-thumbs"]; Length /@ {xy, thumbs} MapThread[Labeled, {thumbs[[;; 5]], xy[[;; 5]]}] </code></pre> <p><a href="https://i.stack.imgur.com/q7Xx3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q7Xx3.png" alt="enter image description here"></a></p> <pre><code>AbsoluteTiming[ data = MapThread[ Inset[#1, #2, Automatic, Scaled[.02]] &amp;, {thumbs, xy}]; g = Graphics[data, ImageSize -&gt; Full]] </code></pre> <p><a href="https://i.stack.imgur.com/uk6CF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uk6CF.png" alt="enter image description here"></a></p> <p>So this doesn't look good yet, and if you zoom in you can see unwanted overlaps:</p> <p><a href="https://i.stack.imgur.com/3q6wV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3q6wV.jpg" alt="enter image description here"></a></p> <p>It requires the 4 steps above, e.g. to conform the images, massage the blob into a centered grid shape with minimal margins, and magnified with callouts and exported to PDF.</p> <p><strong>Possible solutions:</strong></p> <ul> <li>Using <code>WordCloud</code> to pack them?</li> <li>Using <code>ExternalFunction</code> with some python libraries? </li> </ul> https://mathematica.stackexchange.com/q/193253 0 Pixel-wise image manipulation user115376 https://mathematica.stackexchange.com/users/40343 2019-03-14T16:28:17Z 2019-03-14T17:47:31Z <p>I downloaded an image from a website and imported it to Mathematica</p> <pre><code>img = Import["https://i.stack.imgur.com/fPZM7.jpg"]; Export["/path/to/file/fPZM7.txt", Flatten[MapIndexed[Join[#2, #1] &amp;, ImageData[img], {2}], 1], "Table"] </code></pre> <p>and create a .txt file with the pixel information</p> <pre><code>{{1, 1, 0.219608, 0.215686, 0.196078}, {1, 2, 0.219608, 0.215686, 0.196078}, {1, 3, 0.219608, 0.215686, 0.196078}, {1, 4, 0.219608, 0.215686, 0.196078}, {1, 5, 0.219608, 0.215686, 0.196078}, ..... , {944, 1396, 0.054902, 0.054902, 0.0470588}, {944, 1397, 0.00392157, 0.00784314, 0.}, {944, 1398, 0.00784314, 0.0117647, 0.}, {944, 1399, 0.0470588, 0.0509804, 0.027451}, {944, 1400, 0.0588235, 0.0627451, 0.0313725}} </code></pre> <p>which is a list of positions located at integer numbers followed by three real numbers defining the RGB color information of each point.</p> <p>Then I import the <code>.txt</code> file</p> <pre><code>import = Import["/path/to/file/fPZM7.txt", "Data"] </code></pre> <p>and reconstruct the image using the basic code </p> <pre><code>Show[ Table[ Graphics[{ RGBColor[import[[i, 3]], import[[i, 4]], import[[i, 5]]], Point[{import[[i, 1]], import[[i, 2]]}] }], {i, 1, Length[import]} ] ] </code></pre> <p>So far, the image is reconstructed (after a long long time) with no issues. However, if instead I want to manipulate the positions of the pixels, like</p> <pre><code>Show[Table[Graphics[{RGBColor[import[[i, 3]], import[[i, 4]], import[[i, 5]]], Point[{import[[i, 1]], import[[i, 2]]^2}]}], {i, 1, Length[import]}]] </code></pre> <p>or</p> <pre><code>Show[Table[Graphics[{RGBColor[import[[i, 3]], import[[i, 4]], import[[i, 5]]], Point[{import[[i, 1]], Sin[import[[i, 2]]]}]}], {i, 1, Length[import]}]] </code></pre> <p>I get a graphic in blank.</p> <p>Does anybody know what happens there?</p> <p>I would like to be able to manipulate the pixel positions and reconstruct another image out of the original one by changing the position of the pixels. Since all this process takes a lot of time: Does anybody know a more efficient way to plot the image back and the transformation?</p> https://mathematica.stackexchange.com/q/191757 8 Branching points detection in processed image Valacar https://mathematica.stackexchange.com/users/18982 2019-02-18T14:35:31Z 2019-02-19T12:35:55Z <p>I want to get the branching coordinates from a computer-generated image like this one: </p> <p><a href="https://i.stack.imgur.com/7Ck2S.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7Ck2S.png" alt="Generated tree"></a></p> <p>After <code>SkeletonTransform</code> and <code>Pruning</code>, I get:</p> <p><a href="https://i.stack.imgur.com/O0AMj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/O0AMj.png" alt="Skeletonized"></a></p> <p>I would like to develop an algorithm that automatically detect and give coordinates of branching points (I could do it manually but really time consuming).</p> <p>Thanks!</p> <p>Edit: I already tried <code>MorphologicalBranchPoints</code> with poor results...</p> https://mathematica.stackexchange.com/q/187710 1 Numeric data from a color map TeM https://mathematica.stackexchange.com/users/32491 2018-12-11T17:10:05Z 2018-12-11T17:52:48Z <p>Importing the following image (without a scale):</p> <p><a href="https://i.stack.imgur.com/US42T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/US42T.png" alt="enter image description here"></a></p> <p>and knowing the extreme temperatures, is it possible to obtain the graduated scale? </p> <p>Also, it would be interesting to get the temperatures of all the points by moving the cursor over the image.</p> <p>Thanks a lot!</p> https://mathematica.stackexchange.com/q/183174 12 Converting image into graphics t-smart https://mathematica.stackexchange.com/users/53560 2018-10-05T10:36:04Z 2018-10-06T09:05:20Z <p>I have a black-white image, but it is rather blurry so I was thinking of converting it into vector graphics so I could do some coloring. This is the image:</p> <pre><code>img = Import["https://i.stack.imgur.com/cyHjC.jpg"]; </code></pre> <p><a href="https://i.stack.imgur.com/cyHjC.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/cyHjC.jpg" alt="Source image"></a></p> <p>I used <code>Binarize</code> with <code>ImageGraphics</code>, but the result is not so good:</p> <pre><code>img2 = Binarize[ImageApply[If[Mean@# &lt; 0.9, #, {1, 1, 1}] &amp;, img], 0.8] ImageGraphics[Erosion[img2, 1], 2, Method -&gt; {"LinearSeparable", 10}] </code></pre> <p><a href="https://i.stack.imgur.com/kJ5Mz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kJ5Mz.png" alt="enter image description here"></a></p> <p>As you can see, the lines are pretty rough with weird curves here and there.</p> <p><code>ImageGraphics</code> tends to deal with much more complicated stuff, so I thought maybe it is possible to optimize this with the knowledge that this is a black and white image with only the lines required. But how?</p> https://mathematica.stackexchange.com/q/182835 0 Can Mathematica convert PDF into QR code too? Chen Stats Yu https://mathematica.stackexchange.com/users/14046 2018-09-29T21:48:50Z 2018-09-29T21:48:50Z <p>I recently learned that we can embed a whole PDF file into QR codes. But many online sites are not free for this service.</p> <p>Just wondering if Mathematica can do this? Note I don't want to convert the file into images, then into QR. I would like to preserve the <code>PDF</code> format in the QR code when it's <code>scanned</code>.</p> <p>Thanks.</p> https://mathematica.stackexchange.com/q/178779 3 How to extract graph from microscope image? M.R. https://mathematica.stackexchange.com/users/403 2018-07-22T22:12:23Z 2018-08-27T08:29:51Z <p>I have a microscope image of actin filaments and I'd like to extract the geometry of the bright lines into a <code>Graph</code> object:</p> <p><a href="https://i.stack.imgur.com/xOZg1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xOZg1.jpg" alt="enter image description here"></a></p> <p>Here's what I have so far, using the above image as <code>img</code>:</p> <pre><code>s1 = MaxDetect@ LocalAdaptiveBinarize[img, 8, PerformanceGoal -&gt; "Quality"]; s2 = MaxDetect[s1]; s3 = TopHatTransform[s2, 0.74]; s4 = DeleteSmallComponents[s2 - s3]; HighlightImage[img, s4] </code></pre> <p><a href="https://i.stack.imgur.com/w0asV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w0asV.png" alt="enter image description here"></a></p> <p>But this misses lots of lines and the output isn't really a skeleton.</p> <p>Here are a few more example images of the cytoskeleton to try this on:</p> <pre><code>example1 = CloudGet["https://www.wolframcloud.com/objects/defc77bb-8218-4660-9fb2-d851c1145cae"] example2 = CloudGet["https://www.wolframcloud.com/objects/b44045ec-f7ce-4db0-82bf-57e86d1967ac"] </code></pre> https://mathematica.stackexchange.com/q/176588 2 Overlap two images and give movement and the result record it in an animated gif Walter https://mathematica.stackexchange.com/users/58499 2018-07-04T02:22:48Z 2018-10-06T15:30:56Z <p>I need to put the circular image 1 in the image with the hole 2 (and cover the gap) the idea is to create an animated gif that shows the image 1 turning to the right and image 2 to the left in a size that can be projected (regular movement). It will be possible to do with mathematica. Beforehand thank you very much.</p> <p>EDIT</p> <blockquote> <p><strong>Something like this, but with 2 images, one turns to one side in the center and the other rotates in the opposite direction</strong></p> </blockquote> <p><a href="https://mathematica.stackexchange.com/questions/83280/how-to-rotate-a-complete-graph-without-image-rescaling-while-rotating">How to rotate a complete graph without image rescaling while rotating</a></p> <p>image 1 </p> <p><a href="https://i.stack.imgur.com/TS3eP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TS3eP.jpg" alt="enter image description here"></a></p> <p>image 2 <a href="https://i.stack.imgur.com/GAuts.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GAuts.png" alt="enter image description here"></a></p> https://mathematica.stackexchange.com/q/175249 10 How to protrude a 2D image wrapped on a 3D surface Awkward Panda https://mathematica.stackexchange.com/users/56986 2018-06-13T19:51:04Z 2018-06-21T16:36:03Z <p>There are a few posts on this theme:</p> <p><a href="https://mathematica.stackexchange.com/questions/3646/how-to-make-a-3d-globe">How to make a 3D globe?</a></p> <p><a href="https://mathematica.stackexchange.com/questions/6700/how-to-render-a-3d-tubular-graphics-from-a-2d-image-path?noredirect=1&amp;lq=1">How to render a 3D tubular graphics from a 2D image path</a></p> <p><a href="https://mathematica.stackexchange.com/questions/6206/how-to-extrude-a-3d-image-from-a-binary-2d-image">How to extrude a 3D image from a binary 2D image</a></p> <p>However I can't quite piece them together. I am looking to take a 2D image wrapped on a 3D surface and protrude the markings.</p> <p>For example: Given an image such as</p> <p><a href="https://i.stack.imgur.com/m7YSX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/m7YSX.png" alt="enter image description here"></a></p> <p>and wrap around an ellipsoid protrude the lines and circles such that half a sphere is present <a href="https://i.stack.imgur.com/Wa96U.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Wa96U.png" alt="enter image description here"></a></p> <p>It would be ideal for the text to be clearly visible as well. <em>EDIT</em> If the text could be engraved that would be amazing!</p> <p>Thanks if anyone fancies having a go! :)</p> https://mathematica.stackexchange.com/q/174428 6 How to find the boundary of a region from a dataset Sumit https://mathematica.stackexchange.com/users/8070 2018-06-01T17:41:18Z 2018-06-02T12:52:41Z <p>I have a dataset which supposed to show some regions. For example</p> <pre><code>r1 = Disk[{-0.1, -0.1}, 0.5]; r2 = Disk[{0.7, 0.5}, 0.2]; ran = 0.25; (*random amplitude*) f[x_, y_] := Which[RegionMember[r1, {x, y}], 1 + RandomReal[{-ran, ran}], RegionMember[r2, {x, y}], -1 + RandomReal[{-ran, ran}], True, RandomReal[{-ran, ran}]] data = Table[{x, y, f[x, y]}, {x, 0, 1, 0.02}, {y, 0, 0.8, 0.02}]~ Flatten~1; ListDensityPlot[data, InterpolationOrder -&gt; 0, PlotRange -&gt; All, AspectRatio -&gt; 4/5] </code></pre> <p><a href="https://i.stack.imgur.com/IeLeY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IeLeY.png" alt="enter image description here"></a></p> <p>And I want to extract the edges of the <code>r1</code> and <code>r2</code>.</p> <p>I try to convert the <code>data</code> into an <code>image</code> and use <code>EdgeDetect</code>.</p> <pre><code>ndat = Length[data] {zmin, zmax} = MinMax@data[[All, 3]] Do[If[data[[n, 1]] != data[[n + 1, 1]], ny = n; Break[]], {n, ndat}]; nx = ndat/ny; imdata = Partition[data[[All, 3]], ny]; imdata = Table[(imdata[[j, ny - i + 1]] - zmin)/(zmax - zmin), {i, ny}, {j, nx}]; img = Image[imdata]; pts = PixelValuePositions[EdgeDetect[img], 1]; pts = Partition[data[[All, 1 ;; 2]], ny][[#[], #[]]] &amp; /@ pts; ListDensityPlot[data, InterpolationOrder -&gt; 0, PlotRange -&gt; All, AspectRatio -&gt; 4/5, Epilog -&gt; {Red, Point[pts]}] </code></pre> <p><a href="https://i.stack.imgur.com/8DYW5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8DYW5.png" alt="enter image description here"></a></p> <p>In this way, </p> <ol> <li><p>I cannot isolate the regions - for example, the edges of the circle and the quarter circle in the corner.</p></li> <li><p>I cannot find a smooth line for the edges.</p></li> <li><p>It does not work very well when I increase the noise (say <code>ran=0.5</code>).</p></li> </ol> <p>How to find the separate edges as isolated lines/lists?</p> https://mathematica.stackexchange.com/q/173599 1 Import two Gif files together and play them with just one button KratosMath https://mathematica.stackexchange.com/users/53039 2018-05-20T17:00:45Z 2018-05-21T10:24:51Z <p>I have two gif files and I want to import and play them at the same time with just one play button. The target is to compare them easily. Is there any way?</p> https://mathematica.stackexchange.com/q/173200 1 Remove a specific color (black) within an image [closed] juan muñoz https://mathematica.stackexchange.com/users/26745 2018-05-15T03:27:29Z 2018-05-16T01:54:27Z <p>I need the image to be totally blank, so the black must disappear</p> <p><a href="https://i.stack.imgur.com/ZbOG5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZbOG5.png" alt="enter image description here"></a></p> https://mathematica.stackexchange.com/q/171934 2 Masking an image with an annulus Juan Manuel Gomba https://mathematica.stackexchange.com/users/57857 2018-04-25T21:28:25Z 2018-04-26T16:38:07Z <p>I have an image where I would like to do 2 things:</p> <p>a) Put a disk of radius r on an specific $\{x,y\}$ position on the image such as the result is the original image within the disk and black color outside.</p> <p>My attempt was this, but the resulting image within the disk looks different</p> <pre><code> i = Import["http://exampledata.wolfram.com/coneflower.jpg"] DiskRec[x_, y_, rr_] := Graphics@Disk[{x, y}, rr]; HighlightImage[i, DiskRec[45, 40, 30], Method -&gt; "Brightness"]; ImageSubtract[i,HighlightImage[i, DiskRec[45, 40, 30], Method -&gt; "Brightness"]] </code></pre> <p>b)Then, I would like to draw a black circle within the previous one, with a smaller.</p> <p>Thanks in advance, Juan.</p> https://mathematica.stackexchange.com/q/171755 43 How can I draw a Homer with epicycloids? [duplicate] anderstood https://mathematica.stackexchange.com/users/18767 2018-04-23T20:02:59Z 2018-10-12T02:09:20Z <div class="question-status question-originals-of-duplicate"> <p>This question already has an answer here:</p> <ul> <li> <a href="/questions/100051/dynamic-epicycles" dir="ltr">Dynamic Epicycles</a> <span class="question-originals-answer-count"> 4 answers </span> </li> <li> <a href="/questions/118834/how-to-graph-the-contour-of-a-resulting-manipulate-curve" dir="ltr">How to graph the contour of a resulting Manipulate curve</a> <span class="question-originals-answer-count"> 2 answers </span> </li> </ul> </div> <p>You may have seen this video: <a href="https://www.youtube.com/watch?v=QVuU2YCwHjw" rel="noreferrer">https://www.youtube.com/watch?v=QVuU2YCwHjw</a>.</p> <p>How does this work, and how to do it with <em>Mathematica</em>?</p> https://mathematica.stackexchange.com/q/167900 11 How to make Texture unblurred? matheorem https://mathematica.stackexchange.com/users/4742 2018-03-14T02:36:10Z 2018-03-14T13:03:38Z <p>This post is related to <a href="https://mathematica.stackexchange.com/questions/34567/texture-not-working-properly-with-image-alphachannel">this post</a>, But somewhat different. Since Wizard focus on alpha channel, and didn't got an answer. So I made this post.</p> <p>My system is Windows 10, and Mathematica 11.2</p> <p>If I run </p> <pre><code>plot = Image[RandomReal[1., {6, 6}]] </code></pre> <p>I got</p> <p><a href="https://i.stack.imgur.com/96EBs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/96EBs.png" alt="enter image description here"></a></p> <p>Then I texture this image on a square like this</p> <pre><code>Graphics[{Texture[plot], EdgeForm[], Append[Polygon @@ RegionBoundary[Rectangle[]], VertexTextureCoordinates -&gt; {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}] </code></pre> <p>I got</p> <p><a href="https://i.stack.imgur.com/5EonV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5EonV.png" alt="enter image description here"></a></p> <p>You can see it is already blurred</p> <p>What is worse, if we generate a color image</p> <pre><code>plot = Image[RandomReal[1., {6, 6, 3}]] </code></pre> <p><a href="https://i.stack.imgur.com/2MmTy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2MmTy.png" alt="enter image description here"></a></p> <p>and texture it.</p> <pre><code>Graphics[{Texture[plot], EdgeForm[], Append[Polygon @@ RegionBoundary[Rectangle[]], VertexTextureCoordinates -&gt; {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}] </code></pre> <p>I got</p> <p><a href="https://i.stack.imgur.com/aKnNz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/aKnNz.png" alt="enter image description here"></a></p> <p>Which is a total mess.</p> <p>The difference between my result and Wizard's result is that, even I don't set alpha channel, I already screw up the color image texture. </p> <p>So why <code>Texture</code> always blur image? I check the doc, it seems that this blurring feature is not mentioned. Is it possible to make <code>Texture</code> clear especially for color image generated by <code>Image</code>?</p> <hr> <p><strong>update</strong></p> <p>Thanks to J.M. and kglr. They both suggest that it is a problem of low-res of image. But I have a counter example, which suggest that there is some subtle effect. Take a look at this, using <code>ArrayPlot</code></p> <pre><code>plot = ArrayPlot[RandomReal[1., {6, 6}], ColorFunction -&gt; "Rainbow", Frame -&gt; None] </code></pre> <p><a href="https://i.stack.imgur.com/chVkU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/chVkU.png" alt="enter image description here"></a></p> <p>then texture it with the same method, </p> <pre><code>Graphics[{Texture[plot], EdgeForm[], Append[Polygon @@ RegionBoundary[Rectangle[]], VertexTextureCoordinates -&gt; {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}] </code></pre> <p>you will got</p> <p><a href="https://i.stack.imgur.com/iyTjw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iyTjw.png" alt="enter image description here"></a></p> <p>You will notice there is still some blur, but much weaker. And the color is much much better than <code>Image</code> texture, but seems not as vivid as original plot.</p> <p>If you test <code>ImageDimensions@plot</code>. Both <code>ArrayPlot</code> and <code>Image</code> generate 6x6 image. So at least, this example shows low-res may not be a real reason for poor texture of <code>Image</code></p> https://mathematica.stackexchange.com/q/167431 5 How to double (or triple) each element of equation? kittygirl https://mathematica.stackexchange.com/users/54677 2018-03-08T12:09:01Z 2018-03-09T02:51:38Z <pre><code>x^2/3+y^2/9==1 (0.5x)^2/3+(0.5*y)^2/9==1 </code></pre> <p>Looks at above two equation,I multiply 0.5 to each element of second equation,which means when plotting, each point <code>x,y</code> will become <code>2x,2y</code>.I use this method to enlarge plotting object .<br> <a href="https://i.stack.imgur.com/yYbe6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yYbe6.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/nGNvG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nGNvG.png" alt="enter image description here"></a><br> But as to complex equation like <code>y^4+2y^2*x-3xy+7x^3==176.984</code> or <code>r==Sqrt[Sin[2 θ]]</code>,I want to ask how to use mathematica built in function to make it easy? </p> https://mathematica.stackexchange.com/q/160578 1 Prevent Semi-Transparent Pixels in Export ereHsaWyhsipS https://mathematica.stackexchange.com/users/53541 2017-11-24T08:23:27Z 2017-11-24T08:23:27Z <p>I've noticed that when I export plots in Mathematica without a background, a lot of the text ends being made of semi-transparent pixels. For example:</p> <pre><code>myplot = ContourPlot[Cos[x] + Cos[y], {x, 0, 4 Pi}, {y, 0, 4 Pi}, PlotLegends -&gt; Automatic] Export["Output.png", myplot, Background -&gt; None, ImageResolution -&gt; 150] </code></pre> <p>Notice how several of the numbers on the axes contain semi-transparent pixels. In general, is there a way to avoid these altogether while still maintaining the transparent background? The final product still has to be a raster image, unfortunately, so SVG or EPS won't be able to save me here.</p> <p>I also have this problem when I try to use MaTeX, not just in the simple example above. A lot mathematics it renders gets exported with semi-transparent pixels as well.</p> https://mathematica.stackexchange.com/q/159668 34 Drawing Clifford Attractors in Mathematica TreFox https://mathematica.stackexchange.com/users/35769 2017-11-10T16:13:20Z 2017-11-10T17:55:45Z <p>I came upon the "Clifford Attractor" today, which are equations of the form: $$x_{n+1}=\sin(a\ y_n) + c \cos(x_n)$$ $$y_{n+1}=\sin(b\ x_n) + d \cos(y_n)$$ They create some incredible images by choosing different values of $a,b,c,d$: <a href="https://i.stack.imgur.com/6ZKd6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6ZKd6.png" alt="enter image description here"></a></p> <p>With <code>a = -1.24458; b = -1.25191; c = -1.815908; d = -1.90866;</code>, I've been trying to reproduce these in Mathematica using the following code:</p> <pre><code>tbl = RecurrenceTable[{x[n + 1] == Sin[a*y[n]] + c*Cos[a*x[n]], y[n + 1] == Sin[b*x[n]] + d*Cos[a*y[n]], x == 0, y == 0}, {x, y}, {n, 1, 25000}]; ListPlot[tbl, PlotRange -&gt; All, Axes -&gt; False, PlotStyle -&gt; Black] </code></pre> <p>Which produces:</p> <p><a href="https://i.stack.imgur.com/569RJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/569RJ.png" alt="enter image description here"></a></p> <p>Obviously, there is a difference in both of these images. Mostly, the fact that in the first image, the color of each pixel is determined by how many times that point appears. I don't care that the scale of the image is different, but how can I at least approximate the "style" of the first image in Mathematica?</p> https://mathematica.stackexchange.com/q/159101 2 Creating a custom e-seal Vaggelis_Z https://mathematica.stackexchange.com/users/5052 2017-11-02T10:06:32Z 2017-11-02T22:21:13Z <p>Well, the question is obvious: how can I create the following e-seal (with the rotated wrapped text, inserted image etc) with Mathematica? </p> <p><a href="https://i.stack.imgur.com/WIm4b.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WIm4b.jpg" alt="enter image description here"></a></p> <p>The central image is the following</p> <p><a href="https://i.stack.imgur.com/dllfB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dllfB.png" alt="enter image description here"></a></p> <p>So, the following issues should be solved:</p> <p>(1). How to embed an image inside circles.</p> <p>(2). How to wrap text along a circle with a specific radius and orientation. Any good ideas?!</p> <p>Here is my try</p> <pre><code>g1 = Circle[{0, 0}, 1.3]; g2 = Circle[{0, 0}, 1.6]; g3 = Circle[{0, 0}, 1.7]; plot = Graphics[{{Thickness[0.008], g1}, {Thickness[0.008], g2}, {Thickness[0.018], g3}, Inset[img, {0, 0}]}]; Show[plot, ImageSize -&gt; 300] </code></pre> <p><a href="https://i.stack.imgur.com/WfrRY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WfrRY.jpg" alt="enter image description here"></a></p> <p>Now two main things are missing:</p> <p>(a) The wrapped text inside the circles.</p> <p>(b) A way to rotate the central image and control its relative size.</p> <p>Any suggestions? </p> https://mathematica.stackexchange.com/q/149473 1 Extract data from an image of a density plot? JeffDror https://mathematica.stackexchange.com/users/13439 2017-07-01T13:59:46Z 2017-07-02T12:06:44Z <p>I have a density plot in image form and would like to extract the data points from it. How would I go about using <code>Mathematica</code> to accomplish this? My ideal output would be something in list form (x,y,value) so I can use <code>Interpolate</code>. </p> <p>The particular example I have in mind is from <a href="https://arxiv.org/pdf/1612.07818" rel="nofollow noreferrer">here</a> and is shown below: <a href="https://i.stack.imgur.com/rHFPs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rHFPs.png" alt="enter image description here"></a></p> <p>In this example, the whited-out bands are regions where the value is very large (effectively =1) and the vertical axis is a log plot, but presumably these are a minor complications. </p> https://mathematica.stackexchange.com/q/146589 3 Generate coronograph speckle pattern in mathematica Conor Cosnett https://mathematica.stackexchange.com/users/36681 2017-05-22T09:33:51Z 2017-05-22T11:55:58Z <h1>How to simulate the radial coronograph "speckle-noise" in this image?</h1> <p><a href="https://i.stack.imgur.com/eW4Jg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eW4Jg.png" alt="3 exoplanets"></a></p> <blockquote> <p>The 3 circled objects are exoplanets. Their star has been blocked out by a coronagraph, resulting in optical noise known as "speckles".</p> </blockquote> <h2>I am interested in generating the noise (the grainy stuff).</h2> <p>It has to look similar (for the purpose of training a Neural Network to ignore it)</p> <blockquote> <p>I am looking for ideas about how to generating such speckle noise in Mathematica.</p> </blockquote> <hr> <p>Here is one approach using the Fourier transform of random phasors. The trouble is that the speckle elements are not radially oriented in a circle like the image above.</p> <pre><code>(* Program for Simulating Speckle Formation by Free Space Propagation*) n = 2^8; (* Linear dimension of the nxn array to be used.*) k = 2^2; (*number of samples (in one dimension) per speckle. *) start = Table[E^(I 2 \[Pi] * Random[]), {n/k}, {n/k}]; (*generate an n/k \[Times] n/k array of random phasors *) scatterArray = PadRight[start, {n, n}]; (*pad the phasr array with zeros*) (*the scattering spot is a square of size n/k\[Times]n/k *) speckleField = Fourier[scatterArray]; (* Find the FFT of the padded array *) (*this is the speckle field in the observation plane*) speckleIntensity = Abs[speckleField]^2; (*find the intensity of the observed speckle field*) ListDensityPlot[speckleIntensity] </code></pre> <p><a href="https://i.stack.imgur.com/in0DG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/in0DG.png" alt="enter image description here"></a></p> <p>could I stretch it into a circle? Or print it on the side of a cone and view it from above?</p> https://mathematica.stackexchange.com/q/146579 3 Labeling elements of a grid Vaggelis_Z https://mathematica.stackexchange.com/users/5052 2017-05-22T08:26:51Z 2017-05-22T10:17:57Z <p>Let's create a simple $3 \times 3$ grid of images</p> <pre><code>img = ExampleData[{"TestImage", "Lena"}]; P0 = Show[GraphicsGrid[{{img, img, img}, {img, img, img}, {img, img, img}}]] </code></pre> <p><a href="https://i.stack.imgur.com/fdBiP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fdBiP.jpg" alt="enter image description here"></a></p> <p>My question: Is there a quick and elegant way of adding labels (1), (2), ... , (9) at the upper right part of each image? The labels should be located outside the upper right part of each panel, like the following</p> <p><a href="https://i.stack.imgur.com/8iYy4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8iYy4.jpg" alt="enter image description here"></a></p> <p><strong>EDIT</strong></p> <p>Obviously, the above is just a simple case. In my real situation I have a $4 \times 4$ grid containing 16 different images with different names. So the solution must not work only for the same image, repeated many times. </p> <p><strong>EDIT II</strong></p> <p>If I try</p> <pre><code>im0 = Import["Lena.jpg"]; imn0 = Labeled[im0, {Style["(1)", FontFamily -&gt; "Helvetica", 12, Bold]}, {{Top, Right}}]; plot0 = Show[GraphicsGrid[{{imn0, imn0, imn0, imn0}, {imn0, imn0, imn0, imn0}, {imn0, imn0, imn0, imn0}, {imn0, imn0, imn0, imn0}}]] </code></pre> <p>then I get</p> <p><a href="https://i.stack.imgur.com/bPzL9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bPzL9.jpg" alt="enter image description here"></a></p> <p>Why the labels are not shown properly?</p> <p>Any suggestions? </p> https://mathematica.stackexchange.com/q/146405 1 Adding text in images Vaggelis_Z https://mathematica.stackexchange.com/users/5052 2017-05-19T09:57:01Z 2017-05-19T10:55:42Z <p>My question is simple</p> <p>How can I add text in a figure like the following?</p> <p><a href="https://i.stack.imgur.com/M0KgZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M0KgZ.png" alt="enter image description here"></a></p> <p>In particular I want two labels: one at the top "Label text 1" ()just above the image and one at the right side (just outside), written vertically "Label text 2". Of course, I must be able to control the font family, size, etc of the labels.</p> <p>Any suggestions?</p> https://mathematica.stackexchange.com/q/146379 2 reproduce the plot from image Parviz https://mathematica.stackexchange.com/users/43336 2017-05-18T22:00:20Z 2017-05-18T22:14:39Z <p>I need to reproduce the gray plot (H4-WT) of below image.Is there any way for doing that in Mathematica? <a href="https://i.stack.imgur.com/lTsCA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lTsCA.png" alt="enter image description here"></a> </p> https://mathematica.stackexchange.com/q/138702 3 WordCloud out of Images or TeX Wynne https://mathematica.stackexchange.com/users/36616 2017-02-26T17:44:39Z 2018-01-06T17:54:13Z <p>Is it possible to use the WordCloud function to create a word cloud out of LaTeX expressions or images (with transparencies) representing equations?</p> https://mathematica.stackexchange.com/q/136048 1 Make Person Curve from a Picture I-was-a-Ki https://mathematica.stackexchange.com/users/46076 2017-01-24T00:48:31Z 2017-01-24T01:16:27Z <p>I recently read this; <a href="http://blog.wolfram.com/2013/05/17/making-formulas-for-everything-from-pi-to-the-pink-panther-to-sir-isaac-newton/" rel="nofollow noreferrer">http://blog.wolfram.com/2013/05/17/making-formulas-for-everything-from-pi-to-the-pink-panther-to-sir-isaac-newton/</a></p> <p>In this post, newton curve is made by using the image "curveAnnotatedNewtonImage"(In), but I couldn't figure out how this annotation was done.</p> <p>Therefore, I would like to ask you the how to extract feature lines from faces to implement the following FFT calculation.</p> <p>Thank you in advance!</p> https://mathematica.stackexchange.com/q/132085 6 Image with grid lines Shiro Ignis https://mathematica.stackexchange.com/users/44839 2016-11-25T23:39:09Z 2016-11-28T00:06:09Z <p>I have an image of a certain size.</p> <pre><code>img = Image[source, ImageSize -&gt; escala]; </code></pre> <p>I want to add a grid with a scale (0 to maxX from left to right and 0 to maxY from top to bottom). The problem is that <code>GridLines</code> is an option for <code>Graphics</code>, not for <code>Image</code>. </p> <p>How can I overlay grid lines on my image?</p> https://mathematica.stackexchange.com/q/131095 2 graphics - Overlaping Image in red and green scale, mixing pure colors G. Candiotto https://mathematica.stackexchange.com/users/14392 2016-11-14T11:35:01Z 2016-11-20T21:09:48Z <p>How can I overlap/merge two density plot (in attach) using Mathematica. One image is in red scale and the other is in green scale. </p> <p><a href="https://i.stack.imgur.com/BVFot.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BVFot.png" alt="enter image description here"></a></p> <p>In theses two images the lowest value is white (background) and the highest values are represented by pure red [ RGB (255,0,0) ] and green [ RGB (0,255,0) ] scale. </p> <p>How do I to overlap these two images such that intersections are a combination of red and green to give a yellow intensity [ RGB (255,255,0) ] dependent on the "red" and "green" values. <strong>In summary I need that resultant image had red, green and yellow colors</strong>.</p> <p>I already tried these examples:</p> <ul> <li><p><a href="https://mathematica.stackexchange.com/questions/11565/overlapping-red-and-green-arrayplots-to-show-yellow-intersections">Overlapping Red and Green ArrayPlots to show yellow intersections</a> </p></li> <li><p><a href="https://mathematica.stackexchange.com/questions/14836/color-mixing-or-blend/14845#14845">Color mixing or blend</a> </p></li> </ul> <p>and the function <code>Blend[{ Image1 , Image2 }]</code>, but I didn't get a good result.</p> <p>This is the closest example that I get using <strong>Blend[{imag1,imag2}]</strong>.</p> <p><a href="https://i.stack.imgur.com/0FWl7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0FWl7.png" alt="enter image description here"></a></p> <p>But this is not 100 % correct a time that if you combine two pure colors, pure red and green, I was expecting that the combination of these two pure colors result a image that had red, green and yellow colors, but not in the dark tone of these color. </p>