Friday, December 31, 2010

Making anti-aliased diagrams



Even though Mathematica supports anti-aliasing for 3D graphics, it's done inside the video-card which often make computational shortcuts and anti-aliasing quality is sub-optimal. A better way is to rasterize your diagram at higher resolution before exporting, as follows


is=360;
raster=Rasterize[graphic, ImageSize -> is, RasterSize -> 2 is];
Export["~/image.png",raster];


Notebook

8 comments:

  1. Another helpful post.

    ReplyDelete
  2. I run into so many problems when I use Rasterize. Sometimes my graphics aren't even output with the right number of pixels (which I would assume to be the minimum requirement of this function). I use Mathematica 6... can you set the output resolution arbitrarily high? Try 4000 pixels across.

    ReplyDelete
  3. I have not encountered "wrong number of pixels" problem. "Raster" is not optimized for large sizes, for something like 4000 pixels I would use "Image" instead

    ReplyDelete
  4. If you use Image then you loose control of how the rasterization happen, right?

    ReplyDelete
  5. It's same thing, instead of Rasterize use ImageResize with smaller target size. ImageResize has "Resampling" option for more control

    ReplyDelete
  6. This is one of the best tips I've encountered in a long time. Thanks.

    ReplyDelete
  7. Nice post. thank you for sharing with us. I think it would be effective for all which people are want to sale their home. I like this post indeed.
    Mathematica

    ReplyDelete