{"id":2303,"date":"2008-08-29T10:34:45","date_gmt":"2008-08-29T15:34:45","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2008\/08\/29\/smooth-matlab-graphics\/"},"modified":"2016-05-17T14:50:32","modified_gmt":"2016-05-17T18:50:32","slug":"smooth-matlab-graphics","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2008\/08\/29\/smooth-matlab-graphics\/","title":{"rendered":"Smooth MATLAB Graphics"},"content":{"rendered":"<div class=\"content\">\r\n\r\nJiro's pick this week is <a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=20979&amp;objectType=file (link no longer works)\">MYAA<\/a> by Anders Brun.\r\n\r\n&nbsp;\r\n\r\nA few months ago, I wrote a post for Loren's Art of MATLAB blog about <a href=\"https:\/\/blogs.mathworks.com\/loren\/2007\/12\/11\/making-pretty-graphs\/\">creating publication-quality graphics<\/a>. That post was about controlling various properties of graphics objects to make the visualization a higher quality.\r\n\r\nAnother way of making better-looking graphics is to use anti-aliasing. Anti-aliasing provides a smoother look to the lines\r\ndrawn on the screen. PCs use anti-aliasing to make the fonts smoother. With <tt>MYAA<\/tt>, you can easily anti-alias your MATLAB graphics. This is great for both on-screen presentation as well as MATLAB publishing (this blog post is a published document).\r\n\r\n<b>Original Plot<\/b>\r\n\r\nWith the regular screen resolution, you can see the aliasing. It is most apparent with diagonal lines.\r\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\">membrane<\/pre>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/antialias_01.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/>\r\n\r\n<b>Anti-Aliased Plot<\/b>\r\n\r\nAnti-aliased plot looks much smoother. <tt>MYAA<\/tt> supersamples the plot (as an image) and then resizes it (via a filtering method), giving an anti-aliased look.\r\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\">myaa<\/pre>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/antialias_02.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/>\r\n\r\nIf we take a closer look at the two images, you can see the anti-aliasing effect.\r\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\">im1 = imread(<span style=\"color: #a020f0;\">'antialias_01.png'<\/span>);\r\nim2 = imread(<span style=\"color: #a020f0;\">'antialias_02.png'<\/span>);\r\nsubplot(1,2,1);\r\nimshow(im1(100:150, 300:350, :));\r\ntitle(<span style=\"color: #a020f0;\">'Original'<\/span>);\r\nsubplot(1,2,2);\r\nimshow(im2(100:150, 300:350, :));\r\ntitle(<span style=\"color: #a020f0;\">'Anti-Aliased'<\/span>);<\/pre>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/antialias_03.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/>\r\n\r\n<b>More Features<\/b>\r\n\r\n<tt>MYAA<\/tt> has additional features that make it a very handy tool. For example, you can specify the supersampling factor to provide\r\nan even smoother look. The tool also has a nice interactive feature where you can refresh the graphics (after zooming or rotating\r\nthe original plot) or zoom in and out with the anti-aliased plot.\r\n\r\nFinally, I like how Anders has been quickly updating his entry in response to the user feedback. He posted this file early\r\nthis month, and he has already updated several times, making this tool more user-friendly.\r\n\r\n<b>Comments<\/b>\r\n\r\nDo you ever make presentations directly from MATLAB? What are some tricks you employ to make MATLAB a presentation tool? As\r\na starter, I once created a MATLAB animation player for displaying animations. Tell us about your stories <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2303#respond\">here<\/a>.\r\n\r\n<script>\/\/ <![CDATA[\r\nfunction grabCode_ac9a2cb8cd6d4b089b7df4a82b595acf() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='ac9a2cb8cd6d4b089b7df4a82b595acf ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' ac9a2cb8cd6d4b089b7df4a82b595acf';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Jiro Doke';\r\n        copyright = 'Copyright 2008 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('\r\n\r\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\r\n\r\n\r\n\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }\r\n\/\/ ]]><\/script>\r\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\">\r\n<a><span style=\"font-size: x-small; font-style: italic;\">Get\r\nthe MATLAB code\r\n<noscript>(requires JavaScript)<\/noscript><\/span><\/a>\r\n\r\nPublished with MATLAB\u00ae 7.6<\/p>\r\n\r\n<\/div>\r\n<!--\r\nac9a2cb8cd6d4b089b7df4a82b595acf ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadAuthor.do?objectId=1094142&objectType=author % Jiro>'s pick this week is <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=20979&objectType=file % MYAA> by <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadAuthor.do?objectType=author&objectId=1109672 % Anders Brun>.\r\n\r\n%%\r\n% A few months ago, I wrote a post for Loren's Art of MATLAB blog about <https:\/\/blogs.mathworks.com\/loren\/2007\/12\/11\/making-pretty-graphs\/ % creating publication-quality graphics>. That post was about controlling\r\n% various properties of graphics objects to make the visualization a higher\r\n% quality.\r\n%\r\n% Another way of making better-looking graphics is to use anti-aliasing.\r\n% Anti-aliasing provides a smoother look to the lines drawn on the screen.\r\n% PCs use anti-aliasing to make the fonts smoother. With |MYAA|, you can\r\n% easily anti-alias your MATLAB graphics. This is great for both on-screen\r\n% presentation as well as MATLAB\r\n% <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/matlab_env\/f6-14058.html % publishing> (this blog post is a published document).\r\n%\r\n% *Original Plot*\r\n%\r\n% With the regular screen resolution, you can see the aliasing. It is most\r\n% apparent with diagonal lines.\r\n\r\nmembrane\r\n\r\n%%\r\n% *Anti-Aliased Plot*\r\n%\r\n% Anti-aliased plot looks much smoother. |MYAA| supersamples the plot (as\r\n% an image) and then resizes it (via a filtering method), giving an\r\n% anti-aliased look.\r\n\r\nmyaa\r\n\r\n%%\r\n% If we take a closer look at the two images, you can see the anti-aliasing\r\n% effect.\r\n\r\nim1 = imread('antialias_01.png');\r\nim2 = imread('antialias_02.png');\r\nsubplot(1,2,1);\r\nimshow(im1(100:150, 300:350, :));\r\ntitle('Original');\r\nsubplot(1,2,2);\r\nimshow(im2(100:150, 300:350, :));\r\ntitle('Anti-Aliased');\r\n\r\n%%\r\n% *More Features*\r\n%\r\n% |MYAA| has additional features that make it a very handy tool. For\r\n% example, you can specify the supersampling factor to provide an even\r\n% smoother look. The tool also has a nice interactive feature where you can\r\n% refresh the graphics (after zooming or rotating the original plot) or\r\n% zoom in and out with the anti-aliased plot.\r\n%\r\n% Finally, I like how Anders has been quickly updating his entry in\r\n% response to the user feedback. He posted this file early this month, and\r\n% he has already updated several times, making this tool more\r\n% user-friendly.\r\n%\r\n% *Comments*\r\n%\r\n% Do you ever make presentations directly from MATLAB? What are some tricks\r\n% you employ to make MATLAB a presentation tool? As a starter, I once\r\n% created a MATLAB animation player for displaying animations. Tell us\r\n% about your stories <https:\/\/blogs.mathworks.com\/pick\/?p=2303#respond here>.\r\n##### SOURCE END ##### ac9a2cb8cd6d4b089b7df4a82b595acf\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n\r\nJiro's pick this week is MYAA by Anders Brun.\r\n\r\n&nbsp;\r\n\r\nA few months ago, I wrote a post for Loren's Art of MATLAB blog about creating publication-quality graphics. That post was about... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2008\/08\/29\/smooth-matlab-graphics\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2303"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2303"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2303\/revisions"}],"predecessor-version":[{"id":7207,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2303\/revisions\/7207"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}