Tag Info

New answers tagged

5

Avoiding exact calculation by using approximated numerical value before calculation speeds things up. I'm also calculating only the first Eigenvectors as pointed pot by @Öskå. Now it takes only 15 milliseconds time AbsoluteTiming[Chop@Eigenvectors[N[m], 1, Quartics -> True]] {0.015600, {{-0.0725514, -0.106358, -0.0986766, -0.110735 [...] }}}


5

Another way is to use ListConvolve: neighbors = ListConvolve[{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, m, {2, 2}, 0]; neighborCount = ListConvolve[{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, ConstantArray[1, Dimensions@m], {2, 2}, 0]; neighbors/neighborCount == MeanFilter[m, 1] True However, for speed it's not so good to go over the entire matrix in order to ...


0

Simulated annealing will get an algorithm that works the way you want... but will require more careful guidance / tweaking / adaptive adjustment than what I include below: Meas[G_, i_: 0] := Module[{ Ex = EdgeList[G], P = N[PropertyValue[{G, #}, VertexCoordinates] & /@ VertexList[G]] }, Return[If[i == 0, Max[Abs[ Map[Norm[#[[1]] - #[[2]]] &, ...


3

I think the key is Binarize but I couldn't figure out a good way to overlay colored parts on a grayscale image so this is rather hackish. At least it is quite a bit faster than your method: colorize2[image_, α_, β_, γ_, θ_] := ColorCombine[{ ImageSubtract[ImageAdd[img, #1], #2], ImageSubtract[ImageAdd[img, #2], #1], ImageSubtract[img, ##]}] ...


5

something like this? ImageApply[ If[ # < .5, {1, 0, 0}, {0, 1, 0}] &, ExampleData[{"TestImage", "Gray21"}] ] another example, looking again I guess you want to leave gray outside the specified ranges. ImageApply[Piecewise[{ {{1, 0, 0}, .1 < # < .3}, {{0, 0, 1}, .6 < # < .7}, {{#, #, #}, True}}] &, ...


2

Here's a qualitative way to do the computation using FFTs. First, make some data (in this, the disks all have phase 1, but that can be easily fixed): w1 = 600; w2 = 800; dat = Sum[ RotateRight[ DiskMatrix[ RandomInteger[{1, 150}], {w1, w2}], {RandomInteger[{-1000, 1000}], RandomInteger[{-1000, 1000}]}], {k, 6}]; Here's a plot of ...


7

Edit: 4x faster after refactoring and using {# - #2, +##} &[+##, Abs[# - #2]] & instead of Sort/@. Let we have the following 1D intervals $$ [a_1,b_1], [a_2,b_2], [a_3, b_3]. $$ Then we can take all these edges of intervals and sort them. For example, ...



Top 50 recent answers are included