{"id":3438,"date":"2012-04-06T07:57:18","date_gmt":"2012-04-06T12:57:18","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=3438"},"modified":"2016-05-17T21:09:49","modified_gmt":"2016-05-18T01:09:49","slug":"autostereogram","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2012\/04\/06\/autostereogram\/","title":{"rendered":"Autostereogram"},"content":{"rendered":"<div class=\"content\">\r\n\r\n<a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/27649-absird-for-matlab\">abSIRD<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/25696\">Daniel Armyr<\/a>.\r\n\r\nHere's a fun pick for the week. This function takes a matrix, representing a height-map, and visualizes it using an <a href=\"http:\/\/en.wikipedia.org\/wiki\/Autostereogram\">Autostereogram<\/a>. To quote Daniel, \"the algorithm used is abSIRD, published in 2004 by Lewey Geselowitz. It is a fast, in-place algorithm\r\nthat is exquisitely simple to implement.\"\r\n\r\nCan you see them? Hint: cross your eyes.\r\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\">m = membrane(1, 250, 9, 2);\r\nmakeAbsird(m);<\/pre>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_absird\/potw_absird_01.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/>\r\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\">p = load(<span style=\"color: #a020f0;\">'penny'<\/span>);\r\n\r\n<span style=\"color: #228b22;\">% Make it 4 times bigger (imresize from Image Processing Toolbox)<\/span>\r\np2 = imresize(p.P, 4);\r\n\r\nmakeAbsird(p2);<\/pre>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_absird\/potw_absird_02.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/>\r\n\r\nWhat a great way to visualize 3D data!\r\n\r\nI like this entry not only for the coolness factor, but also for how it is written. The code is robustly written with error\r\nchecking and plenty of comments to describe the algorithm. I also like the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/27649-absird-for-matlab\/content\/html\/testMakeAbsird.html\">published example code<\/a> that he included with the entry. These files can be easily created using MATLAB's publishing capability, and it's a great way of showing how to use your code or explaining concepts. I especially like them when they\r\nare used with File Exchange entries.\r\n\r\n<b>Comments<\/b>\r\n\r\nGive this function a try (and cross your eyes) and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=3438#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/27649-absird-for-matlab#comments\">comment<\/a> for Daniel.\r\n\r\n<script>\/\/ <![CDATA[\r\nfunction grabCode_175915dab4fa41fc8abf199ee60f7ebb() {\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='175915dab4fa41fc8abf199ee60f7ebb ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 175915dab4fa41fc8abf199ee60f7ebb';\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 2012 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.14<\/p>\r\n\r\n<\/div>\r\n<!--\r\n175915dab4fa41fc8abf199ee60f7ebb ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007 % Jiro>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/27649-absird-for-matlab abSIRD> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/25696 Daniel % Armyr>.\r\n%\r\n% Here's a fun pick for the week. This function takes a matrix,\r\n% representing a height-map, and visualizes it using an\r\n% <http:\/\/en.wikipedia.org\/wiki\/Autostereogram Autostereogram>. To quote\r\n% Daniel, \"the algorithm used is abSIRD, published in 2004 by Lewey\r\n% Geselowitz. It is a fast, in-place algorithm that is exquisitely simple\r\n% to implement.\"\r\n%\r\n% Can you see them? Hint: cross your eyes.\r\n\r\nm = membrane(1, 250, 9, 2);\r\nmakeAbsird(m);\r\n\r\n%%\r\np = load('penny');\r\n\r\n% Make it 4 times bigger (imresize from Image Processing Toolbox)\r\np2 = imresize(p.P, 4);\r\n\r\nmakeAbsird(p2);\r\n\r\n%%\r\n% What a great way to visualize 3D data!\r\n%\r\n% I like this entry not only for the coolness factor, but also for how it\r\n% is written. The code is robustly written with error checking and plenty\r\n% of comments to describe the algorithm. I also like the\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/27649-absird-for-matlab\/content\/html\/testMakeAbsird.html % published example code> that he included with the entry. These files can\r\n% be easily created using MATLAB's\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/matlab_env\/overview-of-publishing-matlab-code.html % publishing> capability, and it's a great way of showing how to use your\r\n% code or explaining concepts. I especially like them when they are used\r\n% with File Exchange entries.\r\n%\r\n% *Comments*\r\n%\r\n% Give this function a try (and cross your eyes) and let us know what you\r\n% think <https:\/\/blogs.mathworks.com\/pick\/?p=3438#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/27649-absird-for-matlab#comments % comment> for Daniel.\r\n\r\n##### SOURCE END ##### 175915dab4fa41fc8abf199ee60f7ebb\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n\r\nJiro's pick this week is abSIRD by Daniel Armyr.\r\n\r\nHere's a fun pick for the week. This function takes a matrix, representing a height-map, and visualizes it using an Autostereogram. To quote... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2012\/04\/06\/autostereogram\/\">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\/3438"}],"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=3438"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/3438\/revisions"}],"predecessor-version":[{"id":7264,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/3438\/revisions\/7264"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=3438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=3438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=3438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}