function plotembedpos(im,imw,code);

% PLOTEMBEDPOS(im,imw,code);
%
% 		Plots the signature embedding positions
%		and the difference of the original and
% 		the watermarked blue channel.
%
%       im  : original image
%		imw : watermarked image
% 		code: retrieval code produced by WATERMARK
%
%
% University of Rhode Island
% Dept. of Electrical Engineering
% Roger Meier, May '99

RGB=double(im);
RGBw=double(imw);
map=gray(256);

% Decoding code
% -------------
seed=str2num(code(1:4));
density=str2num(code(5:7))/100;
bitlength=str2num(code(8:end));

% Feeding random number generator with seed
% -----------------------------------------
rand('state',seed);

% Calculating embedding positions
% -------------------------------
H=size(RGB,1);
W=size(RGB,2);
emb = (rand(H,W) < density);
[y,x] = find(emb);
pos = [y x];
posnum = length(x);

% Displaying embedding positions
% ------------------------------
imshow(emb)
title(['White Pixels: embedding positions,  Density: ', ...
        num2str(density) ',  Seed: ' num2str(seed)])	  

% Extracting blue channels
% ------------------------
B=RGB(:,:,3);
Bw=RGBw(:,:,3);

% Calculating signature strength
% ------------------------------
dif=Bw-B;
difmax=max(max(dif));
Bmax=max(max(B));
strength=abs(difmax/Bmax);

% Displaying difference between blue channels
% -------------------------------------------
figure
colormap(map)
imagesc(dif)
axis image
axis off
colorbar
title(strvcat('Difference between original and watermarked blue channel', ...
               ['Signature Strength: ' num2str(strength)]))
