?? jpg_gmc.m
字號(hào):
clear;
[s_picture]=imread('quan','jpeg');
[p_a,p_b,p_c]= size(s_picture);
p_s=reshape(s_picture,1,p_a*p_b*p_c);
%p_e=reshape(p_s,p_a,p_b,p_c);
%imwrite(p_e,'quan2','jpeg');
%///////////////////////////transmit
p_double=double(p_s);
data_pic=zeros(1,8*length(p_s));
for i=1:length(p_double);
data_pic(1+(i-1)*8:(i-1)*8+8)=eight2bin(p_double(i));
end
%///////////////////////
%///////////////////////////////////////////recerve
%//////////////////////////
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
K=8;
P=179;
L=3;
M=16;
J=11;
U=ceil(length(data_pic)/8);
sigma=0.07;
%求出R矩陣書(shū)上的11頁(yè)(單位圓上取點(diǎn)),通
R=zeros(M,J);%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
for u=1:M;
for i=1:J;
R(u,i)=exp(j*2*pi*((u-1)+(i-1)*M)/(M*J));%*****************************************R為M*J矩陣
end
end
clear i,j;
R2=R(2,:); % the second user 1*J
%//////////////////////////////////////////////////// /////////////
%/////////////////////////////////////////////////////////////
%求出Thita矩陣,書(shū)上的12頁(yè),VANDERMONDE MATRIX,通
Thita1=zeros(J,K);
for i=1:J;
for j=1:K;
Thita1(i,j)=R2(i).^(-j+1);%***************************************************Thita1 為J*K矩陣
end
end
clear i,j;
%////////////////////////////////////////////////////////////////
S=zeros(K,U);
for i=1:length(data_pic);
S(i)=data_pic(i);
end
for i=1:K;
for j=1:U;
if S(i,j)==0
S(i,j)=-1;
else
S(i,j)=1;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%SS1=reshape(S,1,K*U);%????????????????????????????????????????????????????????????????????????????????????
S1=Thita1*S;
%////////////////////////////////////////////////夾在//之間的程序是通的
%求 信道矩陣]
clear i,j;
h=randn(L+1,M)./sqrt(32)+i*randn(L+1,M)./sqrt(32);%********************************一次隨機(jī)產(chǎn)生后,應(yīng)該是一個(gè)定值,與信道有關(guān) (L+1)*M,
%///////////////////////////////////////////
%/////////////////////////////////////////////////////////////// only the second user
Hm=zeros(M,J);%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
for u=1:M;
for j=1:J;
%for m=1:M;----------------------------------------------------------原來(lái)的錯(cuò)誤使Hm矩陣出現(xiàn)很多個(gè)0
for l=1:L+1;%????????????????????????????????????????????????????????????//書(shū)上是0到L
Hm1=h(l,u)*exp(R(u,j).^(-l+1));
Hm(u,j)=Hm(u,j)+Hm1;%*************************************************************************Hm為M*J矩陣
end
%end
end
end
%////////////////////////////////////////////////////////
for j=1:J;
DuHru2(j,j)=Hm(2,j);%***********************************************************************DuHru為J*J*M矩陣
end
S2=DuHru2*S1;
% NOISE
Gu=zeros(J,P);
for i=1:J;
for j=1:P;
Gu(i,j)=R(i).^(-j+1);%***************************************************Thita1 為J*K矩陣
end
end
clear i,j;
ELTA=sigma.*randn(P,U);
%EITA=sigma.*randn(size(Gu));
noise=Gu*ELTA;
S3=S2+noise;
%////////////////////////////////////////////////////////////////
%%%%%%%%%EQUALIZATION]
Geiu1=DuHru2*Thita1;
Geiu=pinv(Geiu1);
S4=Geiu*S3;
S5=real(S4);%???????????????????????????????????????????????????????????????????????????????? right?
for i=1:K
for j=1:U;
if S5(i,j)<0
S5(i,j)=0;
else
S5(i,j)=1;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%COMPARE
biterror=0;
for i=1:K
for j=1:U;
if S5(i,j)~=S(i,j)
biterror=biterror+1;
end
end
end
biterror
S6=zeros(1,length(data_pic));
for i=1:length(data_pic);
S6(i)=S5(i);
end
output_pic=zeros(1,length((data_pic)/8));
length_output_pic=(length(data_pic))/8;
for i=1:length_output_pic ;
out_pic(i)=bin2eight(S6(1+(i-1)*8:(i-1)*8+8));
end
%%%%%%%%%%%%%%%%%%%%%%
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%/////////////////////////write
p_rec=uint8(out_pic); %*****************************************make picture clear
p_end=reshape(p_rec,p_a,p_b,p_c);
imwrite(p_end,'quan_uncode','jpeg');
%////////////////////////////////////
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -