| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 633 人关注过本帖
标题:图像的边界匹配
只看楼主 加入收藏
郭俊森
Rank: 1
等 级:新手上路
帖 子:27
专家分:3
注 册:2013-2-28
结帖率:57.14%
收藏
 问题点数:0 回复次数:2 
图像的边界匹配
function  bma

clear all
close all
R=imread('1.bmp');
C=imread('2.bmp');%read two frames
R=uint8(R);
figure;imshow(R);


M=288;
N=352;
R=double(R);
C=double(C);

%lose
framesize=M*N;    % 一帧所有像素
   blocksize=8;      % 块的大小
   vnum=M/blocksize; % 垂直方向块个数
   hnum=N/blocksize; % 水平方向块个数
for i=1:vnum
       i1=(i-1)*blocksize+1;
       for j=1:hnum
           j1=(j-1)*blocksize+1;
           if mod(i,2)==0 & mod(j,2)==0 & i~=vnum & j~=hnum               % 离散丢失           
           %if ((i==2 | i==10 | i==14) & j~=1 & j~=hnum)| (i==6 & j>=6 & j<=20) | (i==7 & j>=12 & j<=18) | (i==13 & j>=6 & j<=12) | (i==15 & j>=8 & j<=18)
           %if ((i==2 | i==3) & j~=1 & j~=hnum) | ((i==9 | i==10) & j~=1 & j~=hnum) | ((i==14 | i==15) & j~=1 & j~=hnum)
           %if (mod(i,2)==0 & i~=vnum & j~=1 & j~=hnum) | (mod(i,3)==0 & i~=vnum & j~=1 & j~=hnum)
              concealmentok(i,j)=0;
              for m=0:blocksize-1
                  for n=0:blocksize-1
                      E(i1+m,j1+n)=0;                   % 丢失的像素值以0代替
                  end
              end              
           else
              concealmentok(i,j)=1;
              for m=0:blocksize-1
                  for n=0:blocksize-1
                      E(i1+m,j1+n)=C(i1+m,j1+n);   
                  end
              end
           end
           reMovVector(i,j).x=0;
           reMovVector(i,j).y=0;
       end
   end

   

E=uint8(E);
figure;imshow(E);

imwrite(E,'erro2.bmp');
E=double(E);

%当前帧C图像2,前一帧R图像1,差错帧E图像erro2

tic
 for i=1:vnum                  
     for j=1:hnum
         if concealmentok(i,j)==0
              min=100000;
             for k=(i-1)*blocksize-7:(i-1)*blocksize+9
                 for l=(j-1)*blocksize-7:(j-1)*blocksize+9
                  
                   err2=0;
                   if concealmentok(i,j-1)~=0              % 左
                      for n=1:blocksize
                          
                          err2=err2+abs(R(k+n-1,l)-E((i-1)*blocksize+n,(j-1)*blocksize));
                      end
                  end
                   if concealmentok(i-1,j)~=0              % 上
                      for n=1:blocksize
                           
                          err2=err2+abs(R(k,l+n-1)-E((i-1)*blocksize,(j-1)*blocksize+n));
                      end
                  end
                   if concealmentok(i,j+1)~=0              % 右
                      for n=1:blocksize
                          
                          err2=err2+abs(R(k+n-1,l+blocksize-1)-E((i-1)*blocksize+n,j*blocksize+1));
                      end
                  end
                   if concealmentok(i+1,j)~=0              % 下
                      for n=1:blocksize
                        
                         err2=err2+abs(R(k+blocksize-1,l+n-1)-E(i*blocksize+1,(j-1)*blocksize+n));
                     end
                 end
                 err=err2;
                   if err<=min
                      min=err;
                      reMovVector(i,j).x=(i-1)*blocksize+1-k;             % 运动矢量按像素算
                      reMovVector(i,j).y=(j-1)*blocksize+1-l;
                  end
              end
          end
         
         
         
           for m=1:blocksize
             for n=1:blocksize
                 E((i-1)*blocksize+m,(j-1)*blocksize+n)=R((i-1)*blocksize+m-reMovVector(i,j).x,(j-1)*blocksize+n-reMovVector(i,j).y);
             end
         end
        
            
           concealmentok(i,j)=1;
       end
   end
end
toc
figure;
E=uint8(E);
figure;imshow(E);

imwrite(E,'berrocon21.bmp');
E=double(E);


s=0;                                %计算掩盖后帧与原始帧之间的PSNR
for i=1:M
    for j=1:N
        s=s+(C(i,j)-E(i,j))^2;
    end
end
mse=s/(M*N);
p=10*log10(255*255/mse)
搜索更多相关主题的帖子: function double figure 
2013-09-13 17:13
郭俊森
Rank: 1
等 级:新手上路
帖 子:27
专家分:3
注 册:2013-2-28
收藏
得分:0 
这个出错在哪里?
2013-09-13 17:13
郭俊森
Rank: 1
等 级:新手上路
帖 子:27
专家分:3
注 册:2013-2-28
收藏
得分:0 
运用的时候出现这个  E(i1+m,j1+n)=C(i1+m,j1+n);    错误,希望各位帮忙解决
2013-09-13 17:14
快速回复:图像的边界匹配
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030393 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved