%   RandHarald.m

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.    


PicVec=1
PicInd=1
NPix=2;
ImPath='Paul:Test:'
if PicVec(PicInd)<10
                                                                  
	ImMat=imread([ImPath,'000',num2str(PicVec(PicInd)) '.jpg'],'jpg');
elseif PicVec(PicInd)>9 & PicVec(PicInd)<100
	ImMat=imread([ImPath,'00',num2str(PicVec(PicInd)) '.jpg'],'jpg');
elseif PicVec(PicInd)>99 & PicVec(PicInd)<1000
	ImMat=imread([ImPath,'0',num2str(PicVec(PicInd)) '.jpg'],'jpg');
else
	ImMat=imread([ImPath num2str(PicVec(PicInd)) '.jpg'],'jpg');
end
[m,n,o]=size(ImMat)

RandMat=zeros(m,n);
TakeVec=[1:NPix:m];
SizeTakeVec=size(TakeVec)
ChangeVec=[m:-NPix:1];
SizeChangeVec=size(ChangeVec)
for mInd=1:m
	RandVec=randperm(n);
	RandMat(mInd,:)=RandVec;
	ImMat(mInd,RandVec(TakeVec),:)=ImMat(mInd,RandVec(ChangeVec),:);
end
image(ImMat); 
axis('off');
hold off

