📄 hidetc.m
字号:
function hidetc(u,y)
%-----------------------------------------------------------------------------------------
% HIDETC
% The program hides a text file in an image in true colour;
%
% That is to say of 24 bits or true colour.
% Also hidden the text in images in range of gray (256 ranges of gray)
%
% He is dispersed the text bits in the image.
%
% The syntax is hidetc.
%
% Author: Francisco Echegorri
% E-mail: fdefac@montevideo.com.uy
% Created in September of 2002.
%-----------------------------------------------------------------------------------------
% El programa oculta un archivo de texto en una imagen en color verdadero;
% o sea de 24 bits o true color.Tambien oculta el texto en imagenes en
% escala de grises (256 gamas de gris),con la ventaja de ser una imagen de
% tama駉 mas reducido.
% Para ello dispersa los bits de texto en la imagen.
% La sintaxis es hidetc.
%------------------------------------------------------------------------------------------
if nargin<2
[u, pathname] = uigetfile('*.*', 'To select the Image' );
buffer=pwd;
cd (pathname);
cd (buffer);
[y, pathname] = uigetfile('*.*', 'To select the text file ');
buffer=pwd;
cd (pathname);
cd (buffer);
end
tic,fid=fopen(y,'rt');F=fread(fid);F=char(F)';n=length(F);
[X,map]=imread(u);
if isempty(map)==0
error('The image should be in true color (24 bits) or in range of gray.')
end
dim=size(X);a=dim(1);b=dim(2);max=prod(size(X));
num=n*8+20;
if num>max
disp('The maximum number of characters to hide in the Image is:')
max=num2str(max);disp(max)
disp('The number of characters of the text is:'),num=num2str(num);
disp(num)
error('Too many characters to hide in this Image');
end
desordtext(F);clc,%crypt the text file disordering it for lines and columns.
load htext;m=length(F);t=F;car=8*m+20;
t=[m,t];X=fix(double(X)/2)*2+1;%it transforms the coefficients of X into odd numbers.
y1=nbn(t(1),2);p=2;q=length(y1);y=zeros(1,20-q);y1=[y,y1];y=dec2bin(t(2:m+1));
y=reshape(y',1,8*m);y=double(y)-48*ones(1,8*m);y=[y1,y];
n=0;h=waitbar(0,'Hiding the text in the Image...');
for c=1:3
for i=1:a
if n<=fix(car/b)*b-b
X(i,1:b,c)=X(i,1:b,c)-y(n+1:n+b);n=n+b;waitbar(n/(fix(car/b)*b-b),h)
end
end
end
if length(size(X))==2
c=1;
end
X(i,1:(car-n),c)=X(i,1:(car-n),c)-y((n+1):(car));close(h)
X=uint8(X);
if length(size(X))==2
map=gray(256);colormap(map)
image(X);axis image,zoom on,p=length(u);u=[u(1:p-4)];v=[u,'H.png']; imwrite(X,map,v); disp('El texto oculto esta en:')
disp(v)
else
image(X);axis image,zoom on,p=length(u);u=[u(1:p-4)];
v=[u,'H.png'];imwrite(X,v);fprintf('The text hides this in:\n\n\n')
disp(v)
end
function y=nbn(n,m)
%This program transforms a number n into base 10 in a number in base m.
%The vector y contains the number n in base m.
%Example 365=1031(base 7).
%The syntax is y=nbm(n,m).
%
%Este programa convierte un n鷐ero n en base 10 en un n鷐ero en base m.
%El vector y contiene el n鷐ero n en base m.
%Ejemplo 365=1031(base 7).
%La sintaxis es y=nbm(n,m).
i=1;
while n>=m
x(i)=rem(n,m);n=fix(n/m);i=i+1;
end
x(i)=n;
d=length(x);
y=x(d:-1:1);
q=length(y);
if q<8
yo=zeros(1,8-q);y=[yo,y];
end
fclose('all'),delete htext.mat,toc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -