Matlab彩蛋:那些隐藏的图像的前世今生

记得我使用Matlab的时候曾经遇到一个很诡异的图像,并不是我要现实的内容。当时很惊异。
查资料得知这是matlab的彩蛋。今天看到一篇文章,集中介绍了matlab的这些隐藏图像。觉得挺有意思的,和大家分享一下。原文见链接。先搬过来,有空翻译一下。
------------------------------------------------------------------------------------------------------------------------------------

Image display was added in version 4 of MATLAB, sometime around 1990. Many observant users noticed that the low-level image display object had default pixel values. In other words, if you called image with no input arguments, it would display a small image. If you were a MATLAB 4 user, you might have seen something like this:

When MATLAB 5 was released, some users noticed that the default image had changed.

image
colormap(gray(32))
axis ij

A few users also noticed that the pixel values in the new default image were not integers.

h = findobj(gcf,'type','image');
cdata = get(h,'CData');
cdata(1:3,1:3)
ans =

   11.2307   12.4251   10.4251
   14.4251   15.7483   13.7483
   12.3938   13.7483   12.7483

Is there something interesting about the fractional part?

imagesc(cdata - floor(cdata))

Apparently so.

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 Conference on Image Processing in Atlanta, GA. Now, dear blog readers, you get to hear it, too.

I joined The MathWorks toward the end of 1993. Sometime in 1994, the company held its first employee charity auction. One of the "items" put up for bid was the right to choose the default image for MATLAB 5, which was then under development. As the new "image processing guy" in development, I felt some responsibility to bid. (At least, that's the way I tried to explain it later to my wife.) As it turned out, another MathWorks developer really wanted to win this item, so to win it I ended up paying big bucks. (It's all for charity, I kept reminding myself.)

Once I won the auction, I had to decide what image to pick. During this time, I frequently heard complaints from users that MATLAB could only handle double-precision values. (That lasted until 1997.) Because I heard so much about this issue, I decided that I would use all of the mantissa bits for the new default image. I solicited ideas from my fellow developers for what to include.

Here are the various images "hidden" in different bit slices of the default image pixel values. (To run the code yourself, download this little utility function, bitslice.)

The image stored in the 5 most-significant bits is the one you usually see. This is my oldest son.

defimage = pow2(get(0,'DefaultImageCData'),47);
mag = 200;
imshow(bitslice(defimage,47,51), 'initialmag', mag);

The next 5 bits show a dog that belonged to a MathWorks developer.

imshow(bitslice(defimage,42,46), 'initialmag', mag);

Here's another MathWorks pet.

imshow(bitslice(defimage,37,41), 'initialmag', mag);

This famous matrix is the inverse of the 3-by-3 Hilbert matrix.

imshow(bitslice(defimage,36,36), 'initialmag', mag);

This is a low-resolution version of the company's original logo.

imshow(bitslice(defimage,35,35), 'initialmag', mag);

Loren's favorite number.

imshow(bitslice(defimage,34,34), 'initialmag', mag);

3-by-3 magic square.

imshow(bitslice(defimage,33,33), 'initialmag', mag);

My youngest son.

imshow(bitslice(defimage,28,32), 'initialmag', mag);

A famous magic square hidden in Albrecht Durer's Melancolia.

imshow(bitslice(defimage,23,27), 'initialmag', mag);

I couldn't resist a kind of visual pun. This is the original MATLAB "eight-bit image." (That'll tell you something about my sense of humor.)

imshow(bitslice(defimage,18,22), 'initialmag', mag);

Loren at age 4.

imshow(bitslice(defimage,13,16), 'initialmag', mag);

Wilkinson, Givens, and Forsythe, from the 1964 Gatlinburg Conference on Numerical Algebra.

imshow(bitslice(defimage,9,12), 'initialmag', mag);

Me.

imshow(bitslice(defimage,5,8), 'initialmag', mag);

The original default image from MATLAB 4 is still in there.

imshow(bitslice(defimage,1,4), 'initialmag', mag);

Finally, a certain combination of three bit slices makes a yellow pig with the number 17 superimposed on it. I've been told this is some sort of secret joke within a certain mathematical community.

r = bitslice(defimage,0,0);
g = bitslice(defimage,17,17);
b = bitslice(defimage,34,34);
imshow(cat(3,r,g,b), 'initialmag', mag);

There you have it - the complete story of the MATLAB default image.

代码如下:
%% The Story Behind the MATLAB Default Image
% Image display was added in version 4 of MATLAB, sometime around 1990.  
% Many observant users noticed that the low-level image display object had
% default pixel values.  In other words, if you called |image| with no
% input arguments, it would display a small image.  If you were a MATLAB 4
% user, you might have seen something like this:
%
% <<http://blogs.mathworks.com/images/steve/87/dp.png>>

%%
% When MATLAB 5 was released, some users noticed that the default image had
% changed.

image
colormap(gray(32))
axis ij

%%
% A few users also noticed that the
% pixel values in the new default image were not integers.

h = findobj(gcf,'type','image');
cdata = get(h,'CData');
cdata(1:3,1:3)

%%
% Is there something interesting about the fractional part?

imagesc(cdata - floor(cdata))

%%
% Apparently so.
%
% 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 Conference
% on Image Processing in Atlanta, GA.  Now, dear blog readers, you get to
% hear it, too.
%
% I joined The MathWorks toward the end of 1993.  Sometime in 1994, the
% company held its first employee charity auction.  One of the "items"
% put up for bid was the right to choose the default image for MATLAB 5,
% which was then under development.  As the new "image processing guy" in
% development, I felt some responsibility to bid.  (At least, that's the
% way I tried to explain it later to my wife.)  As it turned out, another
% MathWorks developer really wanted to win this item, so to win it I ended
% up paying big bucks.  (It's all for charity, I kept reminding myself.)
%
% Once I won the auction, I had to decide what image to pick.  During this
% time, I frequently heard complaints from users that MATLAB could only
% handle double-precision values.  (That lasted until 1997.)  Because I 
% heard so much about this issue, I decided that I would use all of the
% mantissa bits for the new default image.  I solicited ideas from my
% fellow developers for what to include.
%
% Here are the various images "hidden" in different bit slices of the
% default image pixel values.  (To run the code yourself, download this
% little utility function, <http://blogs.mathworks.com/images/steve/87/bitslice.m 
% bitslice>.)

%%
% The image stored in the 5 most-significant bits is the one you usually
% see.  This is my oldest son.

defimage = pow2(get(0,'DefaultImageCData'),47);
mag = 200;
imshow(bitslice(defimage,47,51), 'initialmag', mag);

%%
% The next 5 bits show a dog that belonged to a MathWorks developer.

imshow(bitslice(defimage,42,46), 'initialmag', mag);

%%
%
% Here's another MathWorks pet.
imshow(bitslice(defimage,37,41), 'initialmag', mag);

%%
% This famous matrix is the inverse of the 3-by-3 Hilbert matrix.
imshow(bitslice(defimage,36,36), 'initialmag', mag);

%%
% This is a low-resolution version of the company's original logo.
imshow(bitslice(defimage,35,35), 'initialmag', mag);

%%
% Loren's favorite number.
imshow(bitslice(defimage,34,34), 'initialmag', mag);

%%
% 3-by-3 magic square.
imshow(bitslice(defimage,33,33), 'initialmag', mag);

%%
% My youngest son.
imshow(bitslice(defimage,28,32), 'initialmag', mag);

%%
% A famous magic square hidden in Albrecht Durer's Melancolia.
imshow(bitslice(defimage,23,27), 'initialmag', mag);

%%
% I couldn't resist a kind of visual pun.  This is the original MATLAB 
% "eight-bit image."  (That'll tell you something about my sense of humor.)
imshow(bitslice(defimage,18,22), 'initialmag', mag);

%%
% Loren at age 4.
imshow(bitslice(defimage,13,16), 'initialmag', mag);

%%
% Wilkinson, Givens, and Forsythe, from the 1964 Gatlinburg Conference on 
% Numerical Algebra.
imshow(bitslice(defimage,9,12), 'initialmag', mag);

%%
% Me.
imshow(bitslice(defimage,5,8), 'initialmag', mag);

%%
% The original default image from MATLAB 4 is still in there.
imshow(bitslice(defimage,1,4), 'initialmag', mag);

%%
% Finally, a certain combination of three bit slices makes a yellow pig
% with the number 17 superimposed on it.  I've been told this is some sort 
% of secret joke within a certain mathematical community. 
r = bitslice(defimage,0,0);
g = bitslice(defimage,17,17);
b = bitslice(defimage,34,34);
imshow(cat(3,r,g,b), 'initialmag', mag);

%%
% There you have it - the complete story of the MATLAB default image.


%%
% _Steve Eddins_
% _Copyright 2006 The MathWorks, Inc._



  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值