资源简介
用MATLAB实现图象的二维傅里叶变换和二维离散余弦变换,并附有报告和测试程序
代码片段和文件信息
function dct2d = dct2d(Anum)
% A = imread(‘lena.bmp‘);
[row col] = size(A);
% imshow(A);
% title(‘ԭͼ‘);
image = double(A);
N = 8;
a(1) = sqrt(1/N);
a(2:8) = sqrt(2/N);
block = zeros(88); %divided into 8*8 pixel per block
d = zeros(88);
dct2d = zeros(512512);
if num == 1
mask = [1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0];
elseif num == 5
mask = [1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0];
elseif num == 10
mask = [1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0];
else
mask = [1 1 1 1 1 0 0 0
1 1 1 1 1 0 0 0
1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0];
end
for x = 1 : row/N
for y = 1 : col/N
for u = 1 : N
for v = 1 : N
d(uv) = 0;
for i = 1 : N
for j = 1 : N
block(ij) = image(i+(x-1)*8j+(y-1)*8);
d(uv) = d(uv) + block(ij) .* cos((2*(i-1)+1)*(u-1)*pi/(2*N)) .* cos((2*(j-1)+1)*(v-1)*pi/(2*N));
end
end
d(uv) = a(u) .* a(v) .* d(uv);
end
end
dct2d((x-1)*8+1:x*8(y-1)*8+1:y*8) = d .* mask;
% display(d .* mask5)
end
end
% figureimshow(uint8(dct2d));title(‘DCT‘);
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2742 2017-04-07 16:10 5140309350_王宝来_作业1\dct2d.m
文件 353 2017-04-07 14:39 5140309350_王宝来_作业1\DFT2D.m
文件 853 2017-04-07 16:36 5140309350_王宝来_作业1\idct2d.m
文件 382 2017-04-05 17:12 5140309350_王宝来_作业1\IDFT2D.m
文件 263224 2005-08-08 04:51 5140309350_王宝来_作业1\lena.bmp
文件 35000 2017-04-07 10:17 5140309350_王宝来_作业1\lena.jpg
文件 2640 2017-04-07 10:09 5140309350_王宝来_作业1\lena_re.jpg
文件 39143 2017-04-07 10:18 5140309350_王宝来_作业1\lina.jpg
文件 2148 2017-04-07 10:08 5140309350_王宝来_作业1\lina_re.jpg
文件 33320 2017-04-07 16:17 5140309350_王宝来_作业1\PSNR.jpg
文件 248 2017-04-07 15:24 5140309350_王宝来_作业1\PSNR.m
文件 526 2017-04-07 15:08 5140309350_王宝来_作业1\SOL1.m
文件 694 2017-04-07 16:15 5140309350_王宝来_作业1\SOL2.m
文件 82700 2017-04-07 12:20 5140309350_王宝来_作业1\time1.jpg
文件 1182513 2017-04-07 16:48 5140309350_王宝来_作业1\报告.docx
文件 132 2017-04-07 16:50 5140309350_王宝来_作业1\说明.txt
目录 0 2017-04-07 16:49 5140309350_王宝来_作业1
----------- --------- ---------- ----- ----
1646618 17
评论
共有 条评论