{"id":925,"date":"2014-03-17T12:00:24","date_gmt":"2014-03-17T17:00:24","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=925"},"modified":"2014-03-17T18:21:01","modified_gmt":"2014-03-17T23:21:01","slug":"higher-resolution-penny","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2014\/03\/17\/higher-resolution-penny\/","title":{"rendered":"Higher Resolution Penny"},"content":{"rendered":"<div class=\"content\"><!--introduction--><p>High resolution measurements of the depth of the mold for the United States one cent coin provide an interesting data set.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#b909450c-dbb0-4670-b1f9-e090a5f30dca\">Origins<\/a><\/li><li><a href=\"#c0e2e111-5db7-45ef-ae33-fe2179f38a16\">Copper Color Map<\/a><\/li><li><a href=\"#712925d6-43cf-46dc-ac15-32771d1b4ddf\">Surf Plot<\/a><\/li><li><a href=\"#8bbb8200-0983-4b87-a9de-69ad4ab6c5de\">1984<\/a><\/li><li><a href=\"#d3308159-184a-4248-97e5-d6ac774f1c4b\">Contour Plot<\/a><\/li><li><a href=\"#c06df92d-a0b9-462f-a055-d570af0c7fff\">Point Cloud<\/a><\/li><li><a href=\"#56b4bfed-8cf9-4972-b7b6-47cfdd2329d4\">Thanks<\/a><\/li><\/ul><\/div><h4>Origins<a name=\"b909450c-dbb0-4670-b1f9-e090a5f30dca\"><\/a><\/h4><p>During a visit around 1985 to what was then called the National Bureau of Standards, I was shown an instrument that made high resolution measurements of the thickness of small objects.  The instrument would pass a stylus across the object multiple times, recording its height or depth, something like a square phonograph player.  My hosts demonstrated the instrument by measuring the depth of a mold obtained from the United States Mint to make a one cent piece, a penny.<\/p><p>The result is a 512-by-512 array of integers in the range from 0 to 255. Back then, graphics on an array that large was beyond the capacity of MATLAB, so I subsampled the data to produce the 128-by-128 array called <tt>penny.mat<\/tt> that has been distributed in our <tt>demos<\/tt> directory for many years.<\/p><p>Now we can handle the full 512-by-512 array.  Here it is, saved as uint8's. If you want to follow along with this blog on your own machine, click on this link, download the array, and convert it to doubles.<\/p><p><a href=\"https:\/\/blogs.mathworks.com\/images\/cleve\/penny512.mat\">link to penny512.mat<\/a><\/p><pre class=\"codeinput\">   load <span class=\"string\">penny512.mat<\/span>\r\n   P = double(flipud(P));\r\n<\/pre><h4>Copper Color Map<a name=\"c0e2e111-5db7-45ef-ae33-fe2179f38a16\"><\/a><\/h4><p>The <tt>copper<\/tt> colormap is just a linear ramp of rgb values up to a copper color.<\/p><pre class=\"codeinput\">   set(gcf,<span class=\"string\">'renderer'<\/span>,<span class=\"string\">'zbuffer'<\/span>)\r\n   colormap(copper)\r\n   rgbplot(copper)\r\n   title(<span class=\"string\">'copper'<\/span>)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/penny_hi_res_01.png\" alt=\"\"> <h4>Surf Plot<a name=\"712925d6-43cf-46dc-ac15-32771d1b4ddf\"><\/a><\/h4><p>Our first view of the data is a surface plot, with lighting and shading. You have to realize this is not a photograph of a penny. It is a top down view of a three-dimensional surface plot of the depth data obtained from the scanning stylus.  The placement of the light and calculation of its reflections are critical.<\/p><pre class=\"codeinput\">   surf(P);\r\n   shading <span class=\"string\">interp<\/span>\r\n   material <span class=\"string\">metal<\/span>\r\n   lighting <span class=\"string\">gouraud<\/span>\r\n   daspect([1,1,20])\r\n   axis <span class=\"string\">tight<\/span>\r\n   axis <span class=\"string\">off<\/span>\r\n   set(gca,<span class=\"string\">'zlimmode'<\/span>,<span class=\"string\">'auto'<\/span>,<span class=\"string\">'climmode'<\/span>,<span class=\"string\">'manual'<\/span>);\r\n   light(<span class=\"string\">'pos'<\/span>,[1,1,2000],<span class=\"string\">'style'<\/span>,<span class=\"string\">'inf'<\/span>);\r\n   view(2)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/penny_hi_res_02.png\" alt=\"\"> <h4>1984<a name=\"8bbb8200-0983-4b87-a9de-69ad4ab6c5de\"><\/a><\/h4><p>Zoom in on the date.  You can see the striations resulting from the scanning action.<\/p><pre class=\"codeinput\">   surf(P(50:130,360:490));\r\n   shading <span class=\"string\">interp<\/span>\r\n   material <span class=\"string\">metal<\/span>\r\n   lighting <span class=\"string\">gouraud<\/span>\r\n   daspect([1,1,20])\r\n   axis <span class=\"string\">tight<\/span>\r\n   axis <span class=\"string\">off<\/span>\r\n   set(gca,<span class=\"string\">'zlimmode'<\/span>,<span class=\"string\">'auto'<\/span>,<span class=\"string\">'climmode'<\/span>,<span class=\"string\">'manual'<\/span>);\r\n   light(<span class=\"string\">'pos'<\/span>,[1,1,2000],<span class=\"string\">'style'<\/span>,<span class=\"string\">'inf'<\/span>);\r\n   view(2)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/penny_hi_res_03.png\" alt=\"\"> <h4>Contour Plot<a name=\"d3308159-184a-4248-97e5-d6ac774f1c4b\"><\/a><\/h4><p>Now display a contour plot with 20 copper colored contour levels.<\/p><pre class=\"codeinput\">   contour(P,20)\r\n   axis <span class=\"string\">square<\/span>\r\n   axis <span class=\"string\">off<\/span>\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/penny_hi_res_04.png\" alt=\"\"> <h4>Point Cloud<a name=\"c06df92d-a0b9-462f-a055-d570af0c7fff\"><\/a><\/h4><p>Here is a closer three dimensional view with tiny points on the surface.<\/p><pre class=\"codeinput\">   surf(P,<span class=\"string\">'facecolor'<\/span>,<span class=\"string\">'none'<\/span>,<span class=\"string\">'edgecolor'<\/span>,<span class=\"string\">'none'<\/span>,<span class=\"keyword\">...<\/span>\r\n      <span class=\"string\">'marker'<\/span>,<span class=\"string\">'.'<\/span>,<span class=\"string\">'markeredgecolor'<\/span>,<span class=\"string\">'flat'<\/span>,<span class=\"string\">'markersize'<\/span>,1);\r\n   daspect([1,1,20])\r\n   axis <span class=\"string\">tight<\/span>\r\n   axis <span class=\"string\">off<\/span>\r\n   set(gca,<span class=\"string\">'zlimmode'<\/span>,<span class=\"string\">'auto'<\/span>);\r\n   camzoom(3);\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/penny_hi_res_05.png\" alt=\"\"> <h4>Thanks<a name=\"56b4bfed-8cf9-4972-b7b6-47cfdd2329d4\"><\/a><\/h4><p>Thanks to Eric Ludlam and Mike Garrity for help with this post.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_398900004ce64a6db979e8ec294ff373() {\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='398900004ce64a6db979e8ec294ff373 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 398900004ce64a6db979e8ec294ff373';\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        copyright = 'Copyright 2014 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_398900004ce64a6db979e8ec294ff373()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2014a<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2014a<br><\/p><\/div><!--\r\n398900004ce64a6db979e8ec294ff373 ##### SOURCE BEGIN #####\r\n%% Higher Resolution Penny\r\n% High resolution measurements of the depth of the mold for the United States\r\n% one cent coin provide an interesting data set.\r\n\r\n%% Origins\r\n% During a visit around 1985 to what was then called the National Bureau of\r\n% Standards, I was shown an instrument that made high resolution measurements\r\n% of the thickness of small objects.  The instrument would pass a stylus\r\n% across the object multiple times, recording its height or depth, something\r\n% like a square phonograph player.  My hosts demonstrated the instrument by\r\n% measuring the depth of a mold obtained from the United States Mint to\r\n% make a one cent piece, a penny.\r\n\r\n%%\r\n% The result is a 512-by-512 array of integers in the range from 0 to 255.\r\n% Back then, graphics on an array that large was beyond the capacity of\r\n% MATLAB, so I subsampled the data to produce the 128-by-128 array called\r\n% |penny.mat| that has been distributed in our |demos| directory for many\r\n% years.\r\n\r\n%%\r\n% Now we can handle the full 512-by-512 array.  Here it is, saved as uint8's.\r\n% If you want to follow along with this blog on your own machine, click on\r\n% this link, download the array, and convert it to doubles.\r\n% \r\n% <https:\/\/blogs.mathworks.com\/images\/cleve\/penny512.mat link to penny512.mat>\r\n\r\n   load penny512.mat\r\n   P = double(flipud(P));\r\n\r\n%% Copper Color Map\r\n% The |copper| colormap is just a linear ramp of rgb values up to a copper\r\n% color.\r\n\r\n   set(gcf,'renderer','zbuffer')\r\n   colormap(copper)\r\n   rgbplot(copper)\r\n   title('copper')\r\n\r\n%% Surf Plot\r\n% Our first view of the data is a surface plot, with lighting and shading.\r\n% You have to realize this is not a photograph of a penny. It is a top down\r\n% view of a three-dimensional surface plot of the depth data obtained from the\r\n% scanning stylus.  The placement of the light and calculation of its\r\n% reflections are critical.\r\n   \r\n   surf(P);\r\n   shading interp\r\n   material metal\r\n   lighting gouraud\r\n   daspect([1,1,20])\r\n   axis tight\r\n   axis off\r\n   set(gca,'zlimmode','auto','climmode','manual');\r\n   light('pos',[1,1,2000],'style','inf');\r\n   view(2)\r\n\r\n%% 1984\r\n% Zoom in on the date.  You can see the striations resulting from the \r\n% scanning action.\r\n\r\n   surf(P(50:130,360:490));\r\n   shading interp\r\n   material metal\r\n   lighting gouraud\r\n   daspect([1,1,20])\r\n   axis tight\r\n   axis off\r\n   set(gca,'zlimmode','auto','climmode','manual');\r\n   light('pos',[1,1,2000],'style','inf');\r\n   view(2)\r\n\r\n%% Contour Plot\r\n% Now display a contour plot with 20 copper colored contour levels.\r\n\r\n   contour(P,20)\r\n   axis square\r\n   axis off\r\n   \r\n%% Point Cloud\r\n% Here is a closer three dimensional view with tiny points on the surface.\r\n\r\n   surf(P,'facecolor','none','edgecolor','none',...\r\n      'marker','.','markeredgecolor','flat','markersize',1);\r\n   daspect([1,1,20])\r\n   axis tight\r\n   axis off\r\n   set(gca,'zlimmode','auto');\r\n   camzoom(3);\r\n\r\n%% Thanks\r\n% Thanks to Eric Ludlam and Mike Garrity for help with this post. \r\n\r\n##### SOURCE END ##### 398900004ce64a6db979e8ec294ff373\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/feature_image\/penny_hi_res_02.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction--><p>High resolution measurements of the depth of the mold for the United States one cent coin provide an interesting data set.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2014\/03\/17\/higher-resolution-penny\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":1029,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,23,4],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/925"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/comments?post=925"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/925\/revisions"}],"predecessor-version":[{"id":938,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/925\/revisions\/938"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/1029"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}