Executing code in v.5.2 kernel from within v.7.01 session through MathLink

Here is an implementation based on Simon’s code. It still requires improvement. The one unclear thing to me is how to handle Messages generated in the slave (v.5.2) kernel. Here is my code: Clear[linkEvaluate] SetAttributes[linkEvaluate, HoldRest] linkEvaluate[link_LinkObject, expr_] := Catch[ Module[{out = {}, postScript = {}, packet, outputs = {}}, While[LinkReadyQhttps://stackoverflow.com/questions/4983301/executing-code-in-v-5-2-kernel-from-within-v-7-01-session-through-mathlink, Print[“From the buffer:\t”, LinkReadhttps://stackoverflow.com/questions/4983301/executing-code-in-v-5-2-kernel-from-within-v-7-01-session-through-mathlink]]; … Read more

Import big files/arrays with mathematica

For some reason, the current implementation of Import for the type Table (tabular data) is quite memory – inefficient. Below I’ve made an attempt to remedy this situation somewhat, while still reusing Mathematica’s high-level importing capabilities (through ImportString). For sparse tables, a separate solution is presented, which can lead to very significant memory savings. General … Read more

Mathematica: Unevaluated vs Defer vs Hold vs HoldForm vs HoldAllComplete vs etc etc

These are pretty tricky constructs, and it’s tough to give clear explanations; they aren’t as straightforward as Lisp macros (or, for that matter, the relationship between Lisp’s QUOTE and EVAL). However, there’s a good, lengthy discussion available in the form of notes from Robby Villegas’s 1999 talk “Unevaluated Expressions” on Wolfram’s website. Defer is omitted … Read more

Remove White Background from an Image and Make It Transparent

This function implements the reverse blend described by Mark Ransom, for an additional small but visible improvement: reverseBlend[img_Image, alpha_Image, bgcolor_] := With[ {c = ImageData[img], a = ImageData[alpha] + 0.0001, (* this is to minimize ComplexInfinitys and considerably improve performance *) bc = bgcolor}, ImageClip@ Image[Quiet[(c – bc (1 – a))/a, {Power::infy, Infinity::indet}] /. {ComplexInfinity … Read more

How do I find Waldo with Mathematica?

I’ve found Waldo! How I’ve done it First, I’m filtering out all colours that aren’t red waldo = Import[“http://www.findwaldo.com/fankit/graphics/IntlManOfLiterature/Scenes/DepartmentStore.jpg”]; red = Fold[ImageSubtract, #[[1]], Rest[#]] &@ColorSeparate[waldo]; Next, I’m calculating the correlation of this image with a simple black and white pattern to find the red and white transitions in the shirt. corr = ImageCorrelate[red, Image@Join[ConstantArray[1, {2, … Read more