帧内预测matlab程序 :
%%%%%%%帧内预测的垂直模式及两者的对比
a=imread('d:/3.jpg');
[m,n]=size(a);
m=floor(m/16)*16;
n=floor(n/16)*16;
a=rgb2gray(a);
k=min(m,n);
a=imresize(a,[k k]);
subplot(2,2,1),imshow(a,'notruesize')
title('裁减后的图像');
for i=1:k
for j=1:k
b(i,j)=a(i,floor((j-1)/4)*4+1);
end
end
subplot(2,2,2),imshow(b,'notruesize');
title('垂直预测后的图象');
c=imabsdiff(a,b);
subplot(2,2,3),imshow(c,[960 960]);
title('两图象的误差');
for i=1:k
for j=1:k
d(i,j)=a(floor((i-1)/4)*4+1,j);
end
end
subplot(2,2,4),imshow(d,'notruesize');
title('水平预测后的图象');
%%%%求SAD
for i=1:k
for j=1:k
sad=sum(sum(((a(i,j)-b(i,j))^2)));
end
end
%%%%%帧内预测的水平模式及两者的对比
a=imread('d:/3.jpg');
[m,n]=size(a);
m=floor(m/16)*16;
n=floor(n/16)*16;
a=rgb2gray(a);
k=min(m,n);
a=imresize(a,[k k]);
subplot(2,2,1),imshow(a,'notruesize')
title('裁减后的图像');
for i=1:k
for j=1:k
b(i,j)=a(floor((i-1)/4)*4+1,j);
end
end
subplot(2,2,2),imshow(b,'notruesize');
title('水平预测后的图象');
c=imabsdiff(a,b);
subplot(2,2,3),imshow(c,[960 960]);
title('水平预测后两图象的误差');
for i=1:kfor j=1:kd(i,j)=a(i,floor((j-1)/4)*4+1);endendj=imabsdiff(a,d);subplot(2,2,4),imshow(j,[960 960]);title('利用垂直预测后的两图象的误差');%%%%%%求SADfor i=1:kfor j=1:ksad=sum(sum(((a(i,j)-b(i,j))^2)));endend%%%%%帧内预测的对角模式及两者的对比a=imread('d:/3.jpg');[m,n]=size(a);m=floor(m/16)*16;n=floor(n/16)*16;a=rgb2gray(a);k=min(m,n);a=imresize(a,[k k]);subplot(2,2,1),imshow(a,'notruesize')title('裁减后的图像');for i=1:kfor j=1:kb(i,j)=floor([a(floor((i-1)/4)*4+1,j)+a(i,floor((j-1)/4)*4+1)]/2);endendsubplot(2,2,2),imshow(b,'notruesize');title('对角预测后的图象');c=imabsdiff(a,b);subplot(2,2,3),imshow(c,[960 960]);title('两图象的误差');for i=1:kfor j=1:kd(i,j)=a(floor((i-1)/4)*4+1,j);endendsubplot(2,2,4),imshow(d,'notruesize');title('水平预测后的图象');for i=1:kfor j=1:ksad=sum(abs(sum(a(i,j)-b(i,j))));endend