lena图的编码

时间:2017-01-10 13:27:51
【文件属性】:

文件名称:lena图的编码

文件大小:4KB

文件格式:M

更新时间:2017-01-10 13:27:51

灰度图像 matlab

matlab代码实现灰度图像的编码问题Image1=imread('Lena.tiff'); w=imread('logo1.bmp'); w=double(w); %xianshi; number=input(' input the number:'); Image1=suoxiao('Lena.tiff',number); [imagem imagen]=size(Image1); Sr=4;Sd=8; Rnum=(imagem/Sr)*(imagen/Sr); Dnum=(imagem/Sd)*(imagen/Sd); Image2=zeros(Dnum,Sr,Sr); %几行几列矩阵 Image2=blkproc(Image1,[Sd/Sr,Sd/Sr],'mean(mean(x))'); %把image图像分成[Sd/Sr,Sd/Sr]像素块进行mean(mean(x))变换 %压缩image1为原来1/2 % there are no eight tranformation for simpleness RBlocks=zeros(Rnum,Sr,Sr); DBlocks=zeros(Dnum,Sd,Sd); DBlocksReduce=zeros(Dnum*8,Sr,Sr); %%取R块,K记标号---------------------------------- for i=1:imagem/Sr for j=1:imagen/Sr k=(i-1)*imagen/Sr+j; RBlocks(k,:,:)=Image1((i-1)*Sr+1:i*Sr,(j-1)*Sr+1:j*Sr); end end %取R块,K记标号---------------------------------- for i=1:imagem/Sd for j=1:imagen/Sd k=(i-1)*imagen/Sd+j; m=Sr;n=Sr; DBlocksReduce(k,:,:)=Image2((i-1)*Sr+1:i*Sr,(j-1)*Sr+1:j*Sr); DBlocksReduce(k+Dnum,:,:)=DBlocksReduce(k,m:-1:1,:); % 行上下翻转===(x轴对称) DBlocksReduce(k+2*Dnum,:,:)=DBlocksReduce(k,:,n:-1:1); % 列左右翻转 ==== y轴对称 DBlocksReduce(k+3*Dnum,:,:)=DBlocksReduce(k,m:-1:1,n:-1:1); % 先行翻,再列翻 旋转180度 DBlocksReduce(k+4*Dnum,:,:)=reshape(DBlocksReduce(k,:,:),Sr,Sr)'; % 关于y=-x对称 A=reshape( DBlocksReduce(k+3*Dnum,:,:),Sr,Sr)'; DBlocksReduce(k+5*Dnum,:,:)=A(:,n:-1:1); % 关于y=x对称 DBlocksReduce(k+6*Dnum,:,:)=imrotate(reshape(DBlocksReduce(k,:,:),Sr,Sr),90); % 逆时针旋转90度 DBlocksReduce(k+7*Dnum,:,:)=imrotate(reshape(DBlocksReduce(k,:,:),Sr,Sr),270); % 逆时针旋转270度 DBlocks(k,:,:)=Image1((i-1)*Sd+1:i*Sd,(j-1)*Sd+1:j*Sd); end end RandDbest=zeros(Rnum,1)+256^3; RandDbests=zeros(Rnum,1); RandDbesto=zeros(Rnum,1); RandDbestj=zeros(Rnum,1); RandDbestr=zeros(4096,1);%ri RandDbestw=zeros(4096,1);%w是将水印分解后的数yi维数组 RandDbesta=zeros(4096,1);%a是参数 RandDbestrw=zeros(4096,1);%rw RandDbestw1=zeros(4096,1);%w*是二维数组 RandDbestw2=zeros(64,64);%变为yi数组


网友评论