% Version 2.1
% Produced By Ahmed Al-Ghazaly
% This Program Insert An Image Into Another Image ..
tic
i=imread('cameraman.tif');
s=double(i);
j=imread('ic.tif');
w=double(j);
[m,n]=size(s);
[g,h]=size(w);
x=dec2bin(s,8); % decimal to binary transformation
y=double(x);
y=y-48;
plane=cell(1,8);
for r=1:8
plane{r}=y(:,r);
end
for r=1:8
planes{r}=reshape(plane{r},m,n);
end
w(m,n)=0;
planes{8}=ones(m,n);
planes{8}=and(planes{8},w); % Adding the WaterMark
for r=1:8
frames(:,:,1,r)=planes{r};
end
iy=zeros(m*n,8);
for r=1:8
iplanes{r}=reshape(planes{r},(m*n),1);
iy(:,r)=iplanes{r}(:,1);
end
iy1=zeros(1,m*n);
for L=1:m*n
for r=1:8
iy1(L)=iy1(L)+iy(L,9-r)*(2^(r-1));
end
end
s_plus_w=reshape(iy1,m,n);
s_plus_w=uint8(s_plus_w);
imwrite(s_plus_w,'ghoz.tif');
imshow('ghoz.tif');
figure,imshow(j)
figure,montage(frames)
toc