{"id":1096,"date":"2015-01-23T15:31:29","date_gmt":"2015-01-23T20:31:29","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/?p=1096"},"modified":"2015-01-23T15:31:29","modified_gmt":"2015-01-23T20:31:29","slug":"what-was-sheraton-trying-to-tell-us","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2015\/01\/23\/what-was-sheraton-trying-to-tell-us\/","title":{"rendered":"What was Sheraton Trying to Tell Us?"},"content":{"rendered":"\r\n<div class=\"content\"><h3>What was Sheraton Trying to Tell Us?<\/h3><p>Today's post is by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495-sean-de-wolski\">Sean de Wolski<\/a> and me.  We spent a few days this week at training for the start of the year, held in a Sheraton hotel.<\/p><p>At the completion of our stay, we each got a note in our rooms. Here is a sample.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2015\/Sheraton.png\" alt=\"\"> <\/p><p>Actually we read this in with the App from the <a href=\"https:\/\/www.mathworks.com\/products\/imaq\/\">Image Acquisition Toolbox<\/a> and cropped the image (<a href=\"https:\/\/www.mathworks.com\/help\/images\/ref\/imcrop.html\"><tt>imcrop<\/tt><\/a> from <a href=\"https:\/\/www.mathworks.com\/products\/image\/\">Image Processing Toolbox<\/a>) to just display the mysterious binary text.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2015\/Sher.png\" alt=\"\"> <\/p><p>Using functionality from the <a href=\"https:\/\/www.mathworks.com\/products\/computer-vision\/\">Computer Vision System Toolbox<\/a>, we then converted our binary text using the <a href=\"https:\/\/www.mathworks.com\/help\/vision\/ref\/ocr.html\"><tt>ocr<\/tt><\/a> (Optical Character Recognition) function.<\/p><pre class=\"codeinput\">Icrop = imread(<span class=\"string\">'Sher.png'<\/span>);\r\nbintext = ocr(Icrop)\r\nstr = bintext.Words;\r\nstr = [str{:}];\r\n<\/pre><pre class=\"codeoutput\">bintext = \r\n  ocrText with properties:\r\n\r\n                      Text: '010101000110100001100001011011100110101100100...'\r\n    CharacterBoundingBoxes: [879x4 double]\r\n      CharacterConfidences: [879x1 single]\r\n                     Words: {14x1 cell}\r\n         WordBoundingBoxes: [14x4 double]\r\n           WordConfidences: [14x1 single]\r\n<\/pre><p>Next guess was how the text was encoded - 4 bits, 8 bits?  We figured 8 was most likely.<\/p><pre class=\"codeinput\">newstr = reshape(str',8,[])';\r\n<\/pre><p>Let's look at the first few lines.<\/p><pre class=\"codeinput\">snip = newstr(1:3,:)\r\n<\/pre><pre class=\"codeoutput\">snip =\r\n01010100\r\n01101000\r\n01100001\r\n<\/pre><p>Could these be text?<\/p><pre class=\"codeinput\">bin2dec(snip)\r\n<\/pre><pre class=\"codeoutput\">ans =\r\n    84\r\n   104\r\n    97\r\n<\/pre><p>These could be ASCII characters!<\/p><p>Have you ever misread an O for a 0?  Or an l for a 1?  We have!  So we decided to program defensively for those and any other weird swaps that might confuse the OCR.<\/p><pre class=\"codeinput\">newstr(newstr == <span class=\"string\">'O'<\/span>) = <span class=\"string\">'0'<\/span>;\r\nnewstr(newstr ~=<span class=\"string\">'0'<\/span>) = <span class=\"string\">'1'<\/span>;\r\n<\/pre><p>Finally let's write out the result.<\/p><pre class=\"codeinput\">message = char(bin2dec(newstr))';\r\n\r\ndisp(message(1:74))\r\ndisp(message(75:end))\r\n<\/pre><pre class=\"codeoutput\">Thank you for your continued loyalty to Sheraton Boston. It is a pleasure \r\nto host Mathworks year after year.\r\n<\/pre><script language=\"JavaScript\"> <!-- \r\n    function grabCode_ce496bdfcc7444a29f525b4dccdc7dc8() {\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='ce496bdfcc7444a29f525b4dccdc7dc8 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' ce496bdfcc7444a29f525b4dccdc7dc8';\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 2015 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_ce496bdfcc7444a29f525b4dccdc7dc8()\"><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; R2014b<br><\/p><\/div><!--\r\nce496bdfcc7444a29f525b4dccdc7dc8 ##### SOURCE BEGIN #####\r\n%% What was Sheraton Trying to Tell Us?\r\n% Today's post is by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495-sean-de-wolski\r\n% Sean de Wolski> and me.  We spent a few days this week at training for\r\n% the start of the year, held in a Sheraton hotel.\r\n%\r\n% At the completion of our stay, we each got a note in our rooms. Here is a\r\n% sample.\r\n%\r\n% <<Sheraton.png>>\r\n% \r\n%\r\n% Actually we read this in with the App from the\r\n% <https:\/\/www.mathworks.com\/products\/imaq\/ Image Acquisition Toolbox> and\r\n% cropped the image (<https:\/\/www.mathworks.com\/help\/images\/ref\/imcrop.html\r\n% |imcrop|> from <https:\/\/www.mathworks.com\/products\/image\/ Image Processing\r\n% Toolbox>) to just display the mysterious binary text.\r\n%\r\n% <<Sher.png>>\r\n%\r\n% Using functionality from the\r\n% <https:\/\/www.mathworks.com\/products\/computer-vision\/ Computer Vision\r\n% System Toolbox>, we then converted our binary text using the\r\n% <https:\/\/www.mathworks.com\/help\/vision\/ref\/ocr.html |ocr|> (Optical\r\n% Character Recognition) function.\r\nIcrop = imread('Sher.png');\r\nbintext = ocr(Icrop)\r\nstr = bintext.Words;\r\nstr = [str{:}];\r\n%% \r\n% Next guess was how the text was encoded - 4 bits, 8 bits?  We figured 8\r\n% was most likely.\r\nnewstr = reshape(str',8,[])';\r\n%%\r\n% Let's look at the first few lines.\r\nsnip = newstr(1:3,:)\r\n%%\r\n% Could these be text?\r\nbin2dec(snip)\r\n%%\r\n% These could be ASCII characters!\r\n%%\r\n% Have you ever misread an O for a 0?  Or an l for a 1?  We have!  So we\r\n% decided to program defensively for those and any other weird swaps that\r\n% might confuse the OCR.\r\nnewstr(newstr == 'O') = '0';\r\nnewstr(newstr ~='0') = '1';\r\n%%\r\n% Finally let's write out the result.\r\nmessage = char(bin2dec(newstr))';\r\n\r\ndisp(message(1:74))\r\ndisp(message(75:end))\r\n\r\n\r\n\r\n##### SOURCE END ##### ce496bdfcc7444a29f525b4dccdc7dc8\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2015\/Sheraton.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\nWhat was Sheraton Trying to Tell Us?Today's post is by Sean de Wolski and me.  We spent a few days this week at training for the start of the year, held in a Sheraton hotel.At the completion of our... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2015\/01\/23\/what-was-sheraton-trying-to-tell-us\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[33,49,27,29],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/1096"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=1096"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/1096\/revisions"}],"predecessor-version":[{"id":1101,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/1096\/revisions\/1101"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=1096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=1096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=1096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}