⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpg_gmc.m

📁 gmc图象传输
💻 M
字号:
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矩阵书上的11页(单位圆上取点),通     
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矩阵,书上的12页,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);%********************************一次随机产生后,应该是一个定值,与信道有关 (L+1)*M,

%///////////////////////////////////////////

%///////////////////////////////////////////////////////////////  only the second user 
Hm=zeros(M,J);%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
for u=1:M;
 for j=1:J;
      %for m=1:M;----------------------------------------------------------原来的错误使Hm矩阵出现很多个0
        for l=1:L+1;%????????????????????????????????????????????????????????????//书上是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');

%////////////////////////////////////





















 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -