16
$\begingroup$

This is half tip, half question. If one tries to put a large amount of data inside the Initialization:>(code) part of a Manipulate, as one may be compelled to do in a Demonstration or where one wants to create a self-contained CDF document, I find that the Front End gets bogged down trying to format the input. One way around this that I've discovered is to embed the data inside a Raster. Thus:

embedded=Framed@Graphics[Raster[bigdata]] (*Framed is so you can see it*)

The visual output is meaningless. But ... you can then cut and paste the Framed object inside your initialization block and get the data out easily

Manipuate[f[data,n],{n,0,1},
Initialization:>(embedded=(*paste cut framed graphic here*);
data=embedded[[1,1,1]])
]

So far as I can tell, this works. But it depends on an abuse of Raster and Graphics. Does anyone have suggestions about alternative means of putting large amounts of data inside a Manipulate?

$\endgroup$
8
  • 2
    $\begingroup$ +1 Great question, had similar problems. Perhaps one can also use Compress. $\endgroup$
    – Ajasja
    Commented Dec 6, 2012 at 14:54
  • 1
    $\begingroup$ Welcome to Mathematica.SE, Seth! $\endgroup$
    – Yves Klett
    Commented Dec 6, 2012 at 14:55
  • $\begingroup$ @Ajasja Which is not dissimilar, since Compress is effectively used by images. $\endgroup$ Commented Dec 6, 2012 at 14:55
  • $\begingroup$ I second Yves. Welcome, Seth! $\endgroup$ Commented Dec 6, 2012 at 14:56
  • $\begingroup$ Would you mind supplying some bigdata to play around with? $\endgroup$
    – Yves Klett
    Commented Dec 6, 2012 at 14:56

1 Answer 1

7
$\begingroup$

Since we were talking about EXIF information yesterday (any compression to be added on top):

data = Image[Circle[] // Graphics, 
  MetaInformation -> {"The Data" -> 
     ExampleData[{"Text", "OriginOfSpecies"}]}]
MetaInformation /. Options[data]

Mathematica graphics

Sorry for blowing up the thread, but this also works nicely, Matryoshka style: Mathematica graphics

$\endgroup$
3
  • $\begingroup$ Clever. Any known restrictions to EXIF data size? $\endgroup$ Commented Dec 6, 2012 at 15:10
  • $\begingroup$ @SjoerdC.deVries good question... from the Mathematica point of view it is simply an option, so internally probably no explicit limit? $\endgroup$
    – Yves Klett
    Commented Dec 6, 2012 at 15:12
  • $\begingroup$ @SjoerdC.deVries also this is MetaInformation and just derived from the EXIF thread. It might be interesting to check if Export and re-Import with EXIF data works. See also this one: What is the maximum size of JPEG metadata? $\endgroup$
    – Yves Klett
    Commented Dec 6, 2012 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.