Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4426 > unrolled thread

Compression of Plot[] to reduce notebook size

Started by"McHale, Paul" <Paul.McHale@excelitas.com>
First post2011-08-16 05:26 +0000
Last post2011-08-19 10:41 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Compression of Plot[] to reduce notebook size "McHale, Paul" <Paul.McHale@excelitas.com> - 2011-08-16 05:26 +0000
    Re: Compression of Plot[] to reduce notebook size "Rolf.Mertig@gmail.com" <rolf.mertig@gmail.com> - 2011-08-19 10:41 +0000

#4426 — Compression of Plot[] to reduce notebook size

From"McHale, Paul" <Paul.McHale@excelitas.com>
Date2011-08-16 05:26 +0000
SubjectCompression of Plot[] to reduce notebook size
Message-ID<j2cv27$hes$1@smc.vnet.net>
I've been trying to reduce the storage requirement of graphics (plots, tables...).  This is very useful in reducing notebook size.  It also makes it much easier to email or paste into Word.  I'm having a hard time meeting all three objectives (Notebook, Outlook and Word).  Rasterize[] works OK until plot points are low.

p1=Plot3D[Sin[x y],{x,0,2 \[Pi]},{y,0,2 \[Pi]},PlotPoints->100];
ByteCount[p1]
Show[p1]
>> 3,222,360

c1=Rasterize[p1,RasterSize->1000];
ByteCount[c1]
Show[c1]
>> 9,613,064

In this case, the original graphic is preferred.  But when I increase the plot information:

p1=Plot3D[Sin[x y],{x,0,2 \[Pi]},{y,0,2 \[Pi]},PlotPoints->300];
ByteCount[p1]
Show[p1]
>> 11,620,992

c1=Rasterize[p1,RasterSize->1000];
ByteCount[c1]
Show[c1]
>> 9,613,064

I have tried saving a Notebook with the following options:

p1=Plot3D[Sin[x y],{x,0,2 \[Pi]},{y,0,2 \[Pi]},PlotPoints->100]
Size is 2,741KB

p1=Plot3D[Sin[x y],{x,0,2 \[Pi]},{y,0,2 \[Pi]},PlotPoints->100];
Rasterize[p1,RasterSize->1000]
Size is 512KB

p1=Plot3D[Sin[x y],{x,0,2 \[Pi]},{y,0,2 \[Pi]},PlotPoints->100];
s=ExportString[p1,"JPEG2000"];
s=ImportString[s,"JPEG2000"];
Show[s]
Size is 222KB

p1=Plot3D[Sin[x y],{x,0,2 \[Pi]},{y,0,2 \[Pi]},PlotPoints->100];
s=ExportString[p1,"PNG"];
s=ImportString[s,"PNG"];
Show[s]
Size is 111KB

Of course, higher plot points is very different:
p1=Plot3D[Sin[x y],{x,0,2 \[Pi]},{y,0,2 \[Pi]},PlotPoints->300]
(*     s=ExportString[p1,"PNG"];
s=ImportString[s,"PNG"];
Show[s] *)
Size is 9,938KB

p1=Plot3D[Sin[x y],{x,0,2 \[Pi]},{y,0,2 \[Pi]},PlotPoints->300];
s=ExportString[p1,"PNG"];
s=ImportString[s,"PNG"];
Show[s]
Size is 108KB

I'm not saying any of this is a surprise.  Just empirically determining how to best optimize the storage and transmission requirements with little impact on quality.  The email size is harder to quantify.

Anyone with guidelines or input I would appreciate it.   Using graphics directly looks the best in all cases.  The size  becomes incredibly large when there are a large number of points.  Compression seems to produce results which vary with image content.  Some look good, some look terrible.  Maybe there are settings to PNG that could improve.

Thanks,
Paul


Paul McHale  |  Electrical Engineer, Energetics Systems  |  Excelitas Technologies Corp.

Phone:   +1 937.865.3004   |   Fax:  +1 937.865.5170   |   Mobile:   +1 937.371.2828
1100 Vanguard Blvd, Miamisburg, Ohio 45342-0312 USA
Paul.McHale@Excelitas.com<mailto:Paul.McHale@perkinelmer.com>
www.excelitas.com<http://www.excelitas.com>


Please consider the environment before printing this e-mail.
This email message and any attachments are confidential and proprietary to Excelitas Technologies Corp. If you are not the intended recipient of this message, please inform the sender by replying to this email or sending a message to the sender and destroy the message and any attachments.
Thank you

[toc] | [next] | [standalone]


#4479

From"Rolf.Mertig@gmail.com" <rolf.mertig@gmail.com>
Date2011-08-19 10:41 +0000
Message-ID<j2leki$nhv$1@smc.vnet.net>
In reply to#4426
Maybe using PerforranceGoal->"Speed" can help? :

In[1]:= p1 =
  Plot3D[Sin[x y], {x, 0, 2 \[Pi]}, {y, 0, 2 \[Pi]},
   PlotPoints -> 300, Mesh -> None];
ByteCount[p1]

Out[1]= 10162400

In[2]:= p2 =
  Plot3D[Sin[x y], {x, 0, 2 \[Pi]}, {y, 0, 2 \[Pi]},
   PlotPoints -> 300, PerformanceGoal -> "Speed"];
ByteCount[p2]

Out[2]= 5752640

In[3]:= ExportString[p1, "NB"] // ByteCount

Out[3]= 8447552

In[4]:= ExportString[p2, "NB"] // ByteCount

Out[4]= 4589408

In[5]:= Shallow[InputForm[p1],5
]

Out[5]//Shallow= Graphics3D[GraphicsComplex[{<<141259>>}, {<<2>>},
Rule[<<2>>]], {Rule[<<2>>], Rule[<<2>>], Rule[<<2>>], Rule[<<2>>],
Rule[<<2>>]}]

In[6]:= Shallow[InputForm[p2],5
]

Out[6]//Shallow= Graphics3D[GraphicsComplex[{<<90000>>}, {<<1>>},
Rule[<<2>>]], {Rule[<<2>>], Rule[<<2>>], Rule[<<2>>], Rule[<<2>>],
Rule[<<2>>]}]

(* ********************* *)

Rolf Mertig

GluonVision GmbH, Berlin, Germany
http://www.gluonvision.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web