Tag Info

New answers tagged

2

If you're using Mathematica 10, you can also use the new Association feature: frame = Association[]; frame[1] = (*picture1*); frame[2] = (*picture2*); In some ways, associations behave more like lists than downvalues: for example, functions like Map and Select work on them directly. If you assign a different variable to an association, you'll get a copy ...


6

You need to select a new data structure. As Leonid Shifrin has written Append[list, element] has a complexity proportional to Length[list] while Append[association, key -> value] is roughly constant time. Another data structure with this same property is linked lists: {newImage, {prevImage, {prevPrevImage,{}}} Any of these two could be used for ...


4

Here's how I'd approach it. Basically, use DownValues and DumpSave: frame[1] = (*picture1*); frame[2] = (*picture2*); DumpSave["filepath.mx",frame] With a fresh Kernel: Get[filepath.mx]; Length@DownValues@frame 2 Also, Obligatory warning about DumpSave: It's platform and version specific.


3

You can fit your data to a plane surface and use ComponentMeasurements to detect the bumps on the surface. data3Ds = Round[data3D, 0.02] // DeleteDuplicates; plane = LinearModelFit[data3D, {x, y}, {x, y}] data3Dp = ParallelMap[{#[[1]], #[[2]], #[[3]] - plane[#[[1]], #[[2]]]} &, data3Ds]; projection = Rasterize[ ...


1

This will not work on version 9... Because there are too much points (about 300295) my laptop can not handle the whole data. The main idea is to use Delaunay triangulation DelaunayMesh in Mathematica. dat = data3D[[1 ;; 3000, All]]; mesh = DelaunayMesh[dat]; HighlightMesh[mesh, {Style[0, Directive[PointSize[Medium], Black]], Style[2, Opacity[0.1]]}] ...


1

After some further experimentation it turns out that the sluggishness of the locators in the LocatorPane can be overcome by eliminating the explicit Return statement from the PlotLabelerFunction. I changed the code as follows: (* updated Dynamic Overlay Code *) Dynamic[ Which[ (* this Which statement is used for responding to toggling of label ...


5

“Tilt-shift” effect depends on the mask. Here is a full blown app with downloadable source code: Digital Tilt-Shift Photography


1

I was always under the impression that a tilt-shift effect was achieved by blurring the top and bottom of a picture. This is supposed to imitate a shallow depth of field. mask = Image @ Table[With[{c = 150 - 50 x/300}, Abs[y - c]/c], {y, 300}, {x, 300}]; ImageFilter[Mean@Flatten@# &, image, 5, Masking -> mask]


3

According to the documentation the coordinate system used by ImageTransformation uses $(w,h)=(1,\alpha)$ where $\alpha$ is the aspect ratio. I'll use an image with aspect ratio 1: img = ExampleData[{"TestImage", "Lena"}]; aspectRatio = Divide @@ ImageDimensions[img] (* Out: 1 *) In order to translate the image we can move each pixel 25% downwards and to ...


10

Here's how you might approach your problem using direct manipulation of pixel data. First create your graphics: InsertImage = DensityPlot[Sqrt[1 - x^2 - y^2], {x, -1, 1}, {y, -1, 1}, Frame -> False, ColorFunction -> (Opacity[Max[Re[#], 0], GrayLevel[Max[Re[#], 0]]] &), ImageSize -> 20, Background -> Opacity[0, Black]] Now rasterize ...


9

Just for the sake of the argument: Your approach needs about 3.2 seconds for 200 insertions on my machine. Consider this {alpha, col} = Transpose[ Table[{Boole[Im[#] == 0], Max[Re[#], 0]} &@Sqrt[1 - x^2 - y^2], {x, -1, 1, 2/33.}, {y, -1, 1, 2/33.}], {2, 3, 1}]; inset = SetAlphaChannel[Image[col], Image[alpha]]; spiral = Table[{256, 256} + ...


4

Here is an example returning 9 lines without additional points: i = Import["http://goo.gl/5R4MAl"]; ii = Closing[Binarize[GradientFilter[ColorNegate@Binarize[i, .55], 2], 0.1], 1]; foo = Select[ImageLines[ii, Segmented -> True], EuclideanDistance @@ #[[1]] > 100 &]; Show[i, Graphics[{Thick, Orange, Line /@ foo}]] Here are the details for foo: ...


2

With SelectComponents you can do it like this: selectBorder[border_] := SelectComponents[ m, "AdjacentBorders", MemberQ[#, border] & ] So that selectBorder /@ {Left, Right, Top, Bottom} gives But there's a problem, as you can see. AdjacentBorder doesn't count elements that don't touch their borders. So a harder question is not how you can ...


2

You can use for example ImageSubtract as follow: j = Import@"http://i.imgur.com/AC0bvkG.png"; k = Binarize[j, FindThreshold[j]]; l = SelectComponents[k, "FilledCircularity", -7]; m = ImageCrop[l]; comp = ComponentMeasurements[m, {"AdjacentBorders", "BoundingBox"}] /. {{_, Right} | {Right, _} -> {Right}, {_, Left} | {Left, _} -> {Left}}; imgdim ...


3

This should solve the problem: ImagePad[ImagePerspectiveTransformation[i2, Round[f[[2]][[1]]], DataRange -> Full], -BorderDimensions[ ImagePerspectiveTransformation[i2, Round[f[[2]][[1]]], DataRange -> Full]]]


17

@Simon Woods points out in a comment that: In fact the delay on the initial run is caused by compiling code to provide the Poisson distribution :-) You can look at ImageColorOperationsDumpiImageEffectPoissonNoise to see how it works internally. Now, although PoissonDistribution can't be compiled, there's nothing stopping the use of my own C++ ...



Top 50 recent answers are included