function [A] =covertext(teksti,many,away,white,fsize,picture)
%Puts text on picture. For example:
%
%covertext('PAPRIKA',10,0,1,2,'peppers.png');

%teksti='PAPRIKA';
%many=0;
%away=0;
%white=0;
%fsize=20;
%picture='peppers.png'

[A,I]=imread(picture);
[n,m,~]=size(A);
nm=max(n,m);
NM1=ceil(nm/150)+1;
if many~=0,
S=2^many;
SS=S^2;
l=length(teksti);
while l<SS
l=length(teksti);
teksti=[teksti,teksti];
end
teksti=teksti(1:SS);
teksti=reshape(teksti,S,S);
end
teksti=teksti';
guva=figure;
h=text(0,1,teksti);
set(h,'FontName','Courier')
set(h,'FontSize',fsize)
axis([0 1 0 1])
axis equal
axis off
box off
set(guva,'PaperUnits','inches','PaperPosition',[0 0 NM1 NM1])
print -dtiff 'kirjoitusta'

[A,I]=imread(picture);
B=imread('kirjoitusta.tif');
B=B(:,:,1);
Max=max(max(B));
[w,r]=find(B<Max);
w0=min(w);w1=max(w);
r0=min(r);r1=max(r);
B=B(w0:w1,r0:r1);
AA=A;
BB=B;
A=double(A);
B=double(B);
[n,m,~]=size(A);
[N,M,~]=size(B);
%K=max(floor(N/n),floor(M/m))+1;
%for k=1:K
%B=[B,B;B,B];
%end
%[N,M,~]=size(B);
nn=min(n,N);
mm=min(m,M);
B=B(1:nn,1:mm,:);
A=A(1:nn,1:mm,:);
B=B(:,:,1);
B=B/max(max(B));
B=round(B);

if away==1,
B=1-B;
end
C=0;
if white==1,
C=(1-B)*max(max(max(A)));
end

A(:,:,1)=A(:,:,1).*B+C;
A(:,:,2)=A(:,:,2).*B+C;
A(:,:,3)=A(:,:,3).*B+C;
A=A/max(max(max(A)));
image(A)


end

