{"id":2337,"date":"2009-12-14T23:23:27","date_gmt":"2009-12-14T15:23:27","guid":{"rendered":"http:\/\/nick.onetwenty.org\/?p=2337"},"modified":"2009-12-14T23:23:27","modified_gmt":"2009-12-14T15:23:27","slug":"stereograms-and-anaglyphs","status":"publish","type":"post","link":"https:\/\/nick.onetwenty.org\/index.php\/2009\/12\/14\/stereograms-and-anaglyphs\/","title":{"rendered":"Stereograms and anaglyphs"},"content":{"rendered":"<p>I&#8217;ve recently been working on various stereographics in preparation for the upcoming <a href=\"http:\/\/www.facepocalypse.com\/2009\/11\/summer-exhibition\/\">Summer exhibition<\/a> (opening next Tuesday at <a href=\"https:\/\/www.littlecreatures.com.au\/\">Little Creatures<\/a>). I&#8217;ve <a href=\"http:\/\/nick.onetwenty.org\/index.php\/2009\/05\/05\/stereo-drawings\/\">previously mentioned<\/a> my love for stereographics, but I wanted to write a post with a bit more detail&#8230;<\/p>\n<p>I&#8217;m technically inclined, mostly work in digital media, and advocate <a href=\"http:\/\/www.opensource.org\/\">open source<\/a> software. Accordingly, when trying to generate stereographics, I tried a bunch of open source programs and ended up writing a few small programs (<a href=\"http:\/\/www.python.org\/\">python<\/a> scripts) to solve problems I encountered.<\/p>\n<p>The two main types of stereographics I&#8217;m interested in are <a href=\"http:\/\/en.wikipedia.org\/wiki\/Anaglyph_image\">anaglyphs<\/a> (red\/blue 3D images) and <a href=\"http:\/\/en.wikipedia.org\/wiki\/Autostereogram\">autostereograms<\/a> (&#8220;magic eye&#8221; images). I also like crossed stereo pairs, since I find them relatively easy to view as 3D images.<\/p>\n<p>Autostereograms are generally created from a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Shadow_mapping\">depth map<\/a> describing a particular viewpoint of a 3D scene, but other stereographics are usually created using a stereo pair of images (representing unique views from two &#8220;eyes&#8221;).<\/p>\n<p>I wanted a stereographics creation process that was accessible to 2D artists, and drawing two unique views (and making sure that they match!) seemed like a very difficult task. However, I figured that many 2D artists would be able to draw greyscale depthmaps. So I went about writing a program to generate stereo pairs when provided with a depth map.<\/p>\n<p>When looking for a depth map to test with, I immediately thought of <a href=\"http:\/\/kazukitakamatsu.web.fc2.com\/\">Kazuki Takamatsu<\/a>&#8216;s work &#8211; which I&#8217;ve always wanted to see realised in 3D.<\/p>\n<p>Here&#8217;s a sample (image resized and used without permission):<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/depth.png\"><img data-attachment-id=\"2342\" data-permalink=\"https:\/\/nick.onetwenty.org\/index.php\/2009\/12\/14\/stereograms-and-anaglyphs\/depth\/\" data-orig-file=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/depth.png?fit=460%2C460&amp;ssl=1\" data-orig-size=\"460,460\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"depth\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/depth.png?fit=300%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/depth.png?fit=460%2C460&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/depth.png?resize=460%2C460\" alt=\"depth\" title=\"depth\" width=\"460\" height=\"460\" class=\"aligncenter size-full wp-image-2342\" srcset=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/depth.png?w=460&amp;ssl=1 460w, https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/depth.png?w=150&amp;ssl=1 150w, https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/depth.png?w=300&amp;ssl=1 300w\" sizes=\"(max-width: 460px) 85vw, 460px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>Fabian Januszewski has written <a href=\"http:\/\/sourceforge.net\/projects\/stereograph\/\">a neat autostereogram generator<\/a> which is conveniently included in the <a href=\"http:\/\/packages.ubuntu.com\/karmic\/stereograph\">Ubuntu package repositories<\/a>. I used &#8220;stereograph&#8221; to generate a basic autostereogram of the above depth map:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereogram.png\"><img data-attachment-id=\"2345\" data-permalink=\"https:\/\/nick.onetwenty.org\/index.php\/2009\/12\/14\/stereograms-and-anaglyphs\/stereogram\/\" data-orig-file=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereogram.png?fit=460%2C460&amp;ssl=1\" data-orig-size=\"460,460\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"stereogram\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereogram.png?fit=300%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereogram.png?fit=460%2C460&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereogram.png?resize=460%2C460\" alt=\"stereogram\" title=\"stereogram\" width=\"460\" height=\"460\" class=\"aligncenter size-full wp-image-2345\" srcset=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereogram.png?w=460&amp;ssl=1 460w, https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereogram.png?w=150&amp;ssl=1 150w, https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereogram.png?w=300&amp;ssl=1 300w\" sizes=\"(max-width: 460px) 85vw, 460px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>Generating stereo pairs (and an anaglyph) was a bit more work. There seemed to be heaps of programs that would generate a depth map given a stereo pair, but I couldn&#8217;t find anything that would generate a stereo pair from a depth map (the <a href=\"http:\/\/docs.gimp.org\/en\/plug-in-displace.html\">displace<\/a> map in the <a href=\"http:\/\/www.gimp.org\/\">GIMP<\/a> seemed like it should work, but I couldn&#8217;t get it to&#8230;)<\/p>\n<p>I knew that simply remapping the source depth map pixels to stereo images would result in gaps, but I was sure that a simple gap-filling algorithm could be used (rather than having to use <a href=\"http:\/\/portal.acm.org\/citation.cfm?id=383300\">splatting<\/a> or other complex <a href=\"http:\/\/en.wikipedia.org\/wiki\/Point_cloud\">point cloud<\/a> rendering techniques).<\/p>\n<p>Here are the results of my first pass at stereo pair generation:<\/p>\n<p><a href=\"https:\/\/i1.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereo.png\"><img data-attachment-id=\"2344\" data-permalink=\"https:\/\/nick.onetwenty.org\/index.php\/2009\/12\/14\/stereograms-and-anaglyphs\/stereo\/\" data-orig-file=\"https:\/\/i1.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereo.png?fit=460%2C230&amp;ssl=1\" data-orig-size=\"460,230\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"stereo\" data-image-description=\"\" data-medium-file=\"https:\/\/i1.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereo.png?fit=300%2C150&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereo.png?fit=460%2C230&amp;ssl=1\" src=\"https:\/\/i1.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereo.png?resize=460%2C230\" alt=\"stereo\" title=\"stereo\" width=\"460\" height=\"230\" class=\"aligncenter size-full wp-image-2344\" srcset=\"https:\/\/i1.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereo.png?w=460&amp;ssl=1 460w, https:\/\/i1.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/stereo.png?w=300&amp;ssl=1 300w\" sizes=\"(max-width: 460px) 85vw, 460px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>There are a few good guides (such as those by <a href=\"http:\/\/spdbv.vital-it.ch\/TheMolecularLevel\/0Help\/StereoView.html\">Gale Rhodes<\/a> and <a href=\"http:\/\/www.starosta.com\/3dshowcase\/ihelp.html\">Boris Starosta<\/a>) on how to view cross stereo pairs such as the above image. (When you can see it in 3D, it&#8217;s pretty striking.)<\/p>\n<p>One of the biggest problems I encountered with gap-filling was that anti-aliased edges represent erroneous depth data. If you imagine a depth map with a white line on a black background, the white line is near the camera and the black background is far away. When the line is anti-aliased, the grey pixels falsely imply that there are small dots floating somewhere between the (white) object and the (black) background.<\/p>\n<p>Unfortunately, most of the depth maps that I found online &#8220;featured&#8221; anti-aliased edges. Fortunately, I should be able to disable anti-aliasing when generating my own depth maps. (Although this <a href=\"https:\/\/bugs.launchpad.net\/inkscape\/+bug\/180612\">apparently isn&#8217;t an option<\/a> when using <a href=\"http:\/\/inkscape.org\/\">Inkscape<\/a>.)<\/p>\n<p>The stereo pair looked good enough to attempt generating an anaglyph. I came across this GIMP script (by <a href=\"http:\/\/www.flickr.com\/photos\/stephpar\">Steph Parker<\/a>) which made it very easy to do. Here are the results (with the original depth map included along with the red and blue layers):<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/anaglyph.png\"><img data-attachment-id=\"2343\" data-permalink=\"https:\/\/nick.onetwenty.org\/index.php\/2009\/12\/14\/stereograms-and-anaglyphs\/anaglyph\/\" data-orig-file=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/anaglyph.png?fit=460%2C460&amp;ssl=1\" data-orig-size=\"460,460\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"anaglyph\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/anaglyph.png?fit=300%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/anaglyph.png?fit=460%2C460&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/anaglyph.png?resize=460%2C460\" alt=\"anaglyph\" title=\"anaglyph\" width=\"460\" height=\"460\" class=\"aligncenter size-full wp-image-2343\" srcset=\"https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/anaglyph.png?w=460&amp;ssl=1 460w, https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/anaglyph.png?w=150&amp;ssl=1 150w, https:\/\/i0.wp.com\/nick.onetwenty.org\/wp-content\/uploads\/2009\/12\/anaglyph.png?w=300&amp;ssl=1 300w\" sizes=\"(max-width: 460px) 85vw, 460px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>I&#8217;ve ordered <a href=\"http:\/\/www.dealextreme.com\/details.dx\/sku.23120\">some 3D glasses<\/a>, but they haven&#8217;t yet arrived. So I&#8217;m not sure if the above image looks alright. (If you have a pair of red\/blue 3D glasses, please let me know how the above image looks in 3D!)<\/p>\n<p>After reading more about anaglyphs, I&#8217;d like to write a script that generates colour (rather than monochromatic) anaglyphs. It looks a bit more involved, but should be worth the effort.<\/p>\n<p>I hope you enjoyed this write-up! No doubt I will post more about stereographics at some point in future. \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve recently been working on various stereographics in preparation for the upcoming Summer exhibition (opening next Tuesday at Little Creatures). I&#8217;ve previously mentioned my love for stereographics, but I wanted to write a post with a bit more detail&#8230; I&#8217;m technically inclined, mostly work in digital media, and advocate open source software. Accordingly, when trying &hellip; <a href=\"https:\/\/nick.onetwenty.org\/index.php\/2009\/12\/14\/stereograms-and-anaglyphs\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Stereograms and anaglyphs&#8221;<\/span><\/a><\/p>\n","protected":false},"author":67,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paLsRH-BH","_links":{"self":[{"href":"https:\/\/nick.onetwenty.org\/index.php\/wp-json\/wp\/v2\/posts\/2337"}],"collection":[{"href":"https:\/\/nick.onetwenty.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nick.onetwenty.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nick.onetwenty.org\/index.php\/wp-json\/wp\/v2\/users\/67"}],"replies":[{"embeddable":true,"href":"https:\/\/nick.onetwenty.org\/index.php\/wp-json\/wp\/v2\/comments?post=2337"}],"version-history":[{"count":20,"href":"https:\/\/nick.onetwenty.org\/index.php\/wp-json\/wp\/v2\/posts\/2337\/revisions"}],"predecessor-version":[{"id":2361,"href":"https:\/\/nick.onetwenty.org\/index.php\/wp-json\/wp\/v2\/posts\/2337\/revisions\/2361"}],"wp:attachment":[{"href":"https:\/\/nick.onetwenty.org\/index.php\/wp-json\/wp\/v2\/media?parent=2337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nick.onetwenty.org\/index.php\/wp-json\/wp\/v2\/categories?post=2337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nick.onetwenty.org\/index.php\/wp-json\/wp\/v2\/tags?post=2337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}