stegano.m

来自「有趣的可视的数值方法 出自网站http://www.mathworks.com」· M 代码 · 共 64 行

M
64
字号
function stegano(p,q)% STEGANO  Investigate steganography in the default image.% The MATLAB "image" function employs "steganography", hiding % images in the low order bits of the data for other images.persistent imageh cdata bits legend m n if nargin == 0 | isempty(cdata)   shg   clf   axes('pos',[.25 .25 .5 .5])   image   imageh = get(gca,'child');   cdata = get(imageh,'cdata')/32;   axis image   axis ij   axis off   for p = 1:52      bits(p) = uicontrol('style','push','pos',[100+7*p,50,6,15], ...      'userdata',p,'callback','stegano(get(gco,''userdata''))');   end   uicontrol('style','push','pos',[230,30,20,15],'string','<', ...      'fontweight','bold','callback','stegano(''<'')')   uicontrol('style','push','pos',[265,30,20,15],'string','-', ...      'fontweight','bold','callback','stegano(''-'')')   uicontrol('style','push','pos',[300,30,20,15],'string','+', ...      'fontweight','bold','callback','stegano(''+'')')   uicontrol('style','push','pos',[335,30,20,15],'string','>', ...      'fontweight','bold','callback','stegano(''>'')')   legend = uicontrol('style','text','pos',[275,70,30,15],'fontweight','bold');   uicontrol('style','push','pos',[430,30,40,15],'string','close', ...      'callback','close(gcf)')   m = 1;   n = 5;endif nargin == 1   if p == '<'      m = m-1; n = n-1;   elseif p == '-'      n = n-1;   elseif p == '+'      n = n+1;   elseif p == '>'      n = n+1; m = m+1;   elseif p <= (m+n)/2      d = n-m; m = p; n = m+d;   else      d = n-m; n = p; m = n-d;   endendif nargin == 2   m = p; n = q;endm = max(min(m,53),1);n = max(min(n,52),0);set(bits([1:m-1 n+1:52]),'background','white')set(bits(m:n),'background','black')if n < m, s = ''; elseif n == m, s = int2str(m);   else, s = [int2str(m) ':' int2str(n)]; endset(legend,'string',s);d = n-m+1;e = min(d,8);set(imageh,'cdata',mod(floor(2^n*cdata),2^d)/2^(d-e)+1)colormap(gray(2^e))

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?