开发者

($VersionNumber < 6) Cropping an exported image in Mathematica

($VersionNumber < 6) Cropping an exported image in Mathematica

This is an animation I made using Mathematica. As can be seen by highlighting the image, the margins at both 开发者_高级运维the left and right sides are too wide. I don't want to have to submit the image to another program just for the cropping, so what do I do to eliminate the whitespace?

Looking at the documentation, ImageMargins and ImageRegion would have been good except that they only apply to the front end. So, what do I do?


I think you will possible find useful these two articles (although the first is for Mathematica 6 and the second is for v.7):

Exporting Pixel-Perfect Graphics in Mathematica

and

Pixel-perfect Graphics, Revisited.


Try using the PlotRegion option.

Here is an example:

Plot[Sin[x], {x, 0, 10}, 
  Axes -> False, Frame -> True, 
  PlotRegion -> {{0.1, 0.9}, {0.1, 0.9}}]

I tested this in v8 after doing <<Version5`Graphics`

($VersionNumber < 6) Cropping an exported image in Mathematica


First, I would try the PlotRangePadding option to your Plot function. If the expression is already rasterized, you can try something like this:

imagelist /. Raster[a_, rest___]:> Raster[Take[#, {10, -10}]& /@ a, rest]

This should chop 10 pixels off either side. The image processing tools in V7 are quite nice and if you are able, I think you'd find the upgrade a very worthwhile investment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜