{"id":87,"date":"2006-10-17T16:01:30","date_gmt":"2006-10-17T20:01:30","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/?p=87"},"modified":"2023-02-03T17:56:45","modified_gmt":"2023-02-03T22:56:45","slug":"the-story-behind-the-matlab-default-image","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2006\/10\/17\/the-story-behind-the-matlab-default-image\/","title":{"rendered":"The Story Behind the MATLAB Default Image"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p>Image display was added in version 4 of MATLAB, sometime around 1990. Many observant users noticed that the low-level image\r\n         display object had default pixel values.  In other words, if you called <tt>image<\/tt> with no input arguments, it would display a small image.  If you were a MATLAB 4 user, you might have seen something like\r\n         this:\r\n      <\/p>\r\n      <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/dp.png\"> <\/p>\r\n   <\/introduction>\r\n   <p>When MATLAB 5 was released, some users noticed that the default image had changed.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">image\r\ncolormap(gray(32))\r\naxis <span style=\"color: #A020F0\">ij<\/span><\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_01.jpg\"> <p>A few users also noticed that the pixel values in the new default image were not integers.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">h = findobj(gcf,<span style=\"color: #A020F0\">'type'<\/span>,<span style=\"color: #A020F0\">'image'<\/span>);\r\ncdata = get(h,<span style=\"color: #A020F0\">'CData'<\/span>);\r\ncdata(1:3,1:3)<\/pre><pre style=\"font-style:oblique\">\r\nans =\r\n\r\n   11.2307   12.4251   10.4251\r\n   14.4251   15.7483   13.7483\r\n   12.3938   13.7483   12.7483\r\n\r\n<\/pre><p>Is there something interesting about the fractional part?<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imagesc(cdata - floor(cdata))<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_02.jpg\"> <p>Apparently so.<\/p>\r\n   <p>I now confess - you can blame me for all of this.  I told this story in public for the first time last week at the IEEE International\r\n      Conference on Image Processing in Atlanta, GA.  Now, dear blog readers, you get to hear it, too.\r\n   <\/p>\r\n   <p>I joined The MathWorks toward the end of 1993.  Sometime in 1994, the company held its first employee charity auction.  One\r\n      of the \"items\" put up for bid was the right to choose the default image for MATLAB 5, which was then under development.  As\r\n      the new \"image processing guy\" in development, I felt some responsibility to bid.  (At least, that's the way I tried to explain\r\n      it later to my wife.)  As it turned out, another MathWorks developer really wanted to win this item, so to win it I ended\r\n      up paying big bucks.  (It's all for charity, I kept reminding myself.)\r\n   <\/p>\r\n   <p>Once I won the auction, I had to decide what image to pick.  During this time, I frequently heard complaints from users that\r\n      MATLAB could only handle double-precision values.  (That lasted until 1997.)  Because I heard so much about this issue, I\r\n      decided that I would use all of the mantissa bits for the new default image.  I solicited ideas from my fellow developers\r\n      for what to include.\r\n   <\/p>\r\n   <p>Here are the various images \"hidden\" in different bit slices of the default image pixel values.  (To run the code yourself,\r\n      download this little utility function, <a href=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/bitslice.m\">bitslice<\/a>.)\r\n   <\/p>\r\n   <p>The image stored in the 5 most-significant bits is the one you usually see.  This is my oldest son.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">defimage = pow2(get(0,<span style=\"color: #A020F0\">'DefaultImageCData'<\/span>),47);\r\nmag = 200;\r\nimshow(bitslice(defimage,47,51));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_03.jpg\"> <p>The next 5 bits show a dog that belonged to a MathWorks developer.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,42,46));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_04.jpg\"> <p>Here's another MathWorks pet.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,37,41));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_05.jpg\"> <p>This famous matrix is the inverse of the 3-by-3 Hilbert matrix.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,36,36));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_06.jpg\"> <p>This is a low-resolution version of the company's original logo.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,35,35));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_07.jpg\"> <p>Loren's favorite number.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,34,34));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_08.jpg\"> <p>3-by-3 magic square.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,33,33));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_09.jpg\"> <p>My youngest son.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,28,32));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_10.jpg\"> <p>A famous magic square hidden in Albrecht Durer's Melancolia.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,23,27));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_11.jpg\"> <p>I couldn't resist a kind of visual pun.  This is the original MATLAB \"eight-bit image.\"  (That'll tell you something about\r\n      my sense of humor.)\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,18,22));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_12.jpg\"> <p>Loren at age 4.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,13,16));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_13.jpg\"> <p>Wilkinson, Givens, and Forsythe, from the 1964 Gatlinburg Conference on Numerical Algebra.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,9,12));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_14.jpg\"> <p>Me.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,5,8));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_15.jpg\"> <p>The original default image from MATLAB 4 is still in there.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">imshow(bitslice(defimage,1,4));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_16.jpg\"> <p>Finally, a certain combination of three bit slices makes a yellow pig with the number 17 superimposed on it.  I've been told\r\n      this is some sort of secret joke within a certain mathematical community.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">r = bitslice(defimage,0,0);\r\ng = bitslice(defimage,17,17);\r\nb = bitslice(defimage,34,34);\r\nimshow(cat(3,r,g,b));<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/87\/default_image_story_17.jpg\"> <p>There you have it - the complete story of the MATLAB default image.<\/p><pre class=\"codeinput\"><span class=\"keyword\">function<\/span> b = bitslice(a,lowbit,highbit)\n<span class=\"comment\">% BITSLICE(A,LOWBIT,HIGHBIT)<\/span>\n<span class=\"comment\">%<\/span>\n<span class=\"comment\">%   Scales return values so that the maximum is 1.0.<\/span>\n\nb = a \/ 2^(lowbit);\nb = fix(b);\nb = b \/ 2^(highbit - lowbit + 1);\nb = b - fix(b);\n\nb = b \/ max(b(:));\n<span class=\"keyword\">end<\/span>\n<\/pre><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><br><br>\r\n      Published with MATLAB&reg; R2021a<br><\/p>\r\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      Image display was added in version 4 of MATLAB, sometime around 1990. Many observant users noticed that the low-level image\r\n         display object had default pixel values.  In other... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2006\/10\/17\/the-story-behind-the-matlab-default-image\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[50,46,58,250,252,56,48,60,36,254],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/87"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"predecessor-version":[{"id":6807,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/87\/revisions\/6807"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}