matlab 图像dct变换 10
想用DCT变换将图像压缩程序怎么写压缩后的图片是怎样的???我试过了!!!DCT后图像看不见了!!!...
想用DCT变换 将图像压缩 程序怎么写 压缩后的图片是怎样的???
我试过了!!!DCT后图像看不见了!!! 展开
我试过了!!!DCT后图像看不见了!!! 展开
展开全部
[A,map]=imread('******');
%显示原图
imshow(A,map),
title('原图');
image=double(A);
N=8;
for x=1,
a(x)=sqrt(1/N);
end,
for x=2:8,
a(x)=sqrt(2/N);
end,
%dct
rimage=zeros(8,8);
for x=1:32,
for y=1:32,
for u=1:N,
for v=1:N,
for i=1:N,
for j=1:N,
rimage(i,j)=image(i+(x-1)*8,j+(y-1)*8);
b(i,j)=rimage(i,j).*cos((2*(i-1)+1)*(u-1)*pi/(2*N)).*cos((2*(j-1)+1)*(v-1)*pi/(2*N));
end,
end,
d(u,v)=sum(sum(b,1),2);
C(u,v)=a(u).*a(v).*d(u,v);
end,
end,
xhimage{x,y}=C;
end,
end,
aa=zeros(8,8);
b1=zeros(256,256);
for x=1:32,
for y=1:32,
aa=xhimage{x,y};
for i=1:8,
for j=1:8,
b1(i+(x-1)*8,j+(y-1)*8)=aa(i,j);
end,
end,
end,
end,
figure,imshow(uint8(b1));title('DCT');
%显示原图
imshow(A,map),
title('原图');
image=double(A);
N=8;
for x=1,
a(x)=sqrt(1/N);
end,
for x=2:8,
a(x)=sqrt(2/N);
end,
%dct
rimage=zeros(8,8);
for x=1:32,
for y=1:32,
for u=1:N,
for v=1:N,
for i=1:N,
for j=1:N,
rimage(i,j)=image(i+(x-1)*8,j+(y-1)*8);
b(i,j)=rimage(i,j).*cos((2*(i-1)+1)*(u-1)*pi/(2*N)).*cos((2*(j-1)+1)*(v-1)*pi/(2*N));
end,
end,
d(u,v)=sum(sum(b,1),2);
C(u,v)=a(u).*a(v).*d(u,v);
end,
end,
xhimage{x,y}=C;
end,
end,
aa=zeros(8,8);
b1=zeros(256,256);
for x=1:32,
for y=1:32,
aa=xhimage{x,y};
for i=1:8,
for j=1:8,
b1(i+(x-1)*8,j+(y-1)*8)=aa(i,j);
end,
end,
end,
end,
figure,imshow(uint8(b1));title('DCT');
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |