|
泊松融合--视频分享
百度网盘链接:链接:http://pan.baidu.com/s/1skOTRul
具体链接在halcom.cn论坛,联系人QQ:3283892722
欢迎大家录制视频,你可在论坛进行打赏分享。
视频专用播放器:http://halcom.cn/forum.php?mod=viewthread&tid=258&extra=page%3D1
泊松融合参考链接:【1】http://cs.brown.edu/courses/csci1950-g/
【2】http://www.cnblogs.com/CVFans/p/4475885.html
- clc,clear,close all
- warning off
- lena = double(imread('lena.png'));
- girl = double(imread('girl.png'));
- [Lh,Lv] = imgrad(lena); % 水平Lh和垂直梯度Lv
- [Gh,Gv] = imgrad(girl); % 水平Gh和垂直梯度Gv
- X = lena;
- Fh = Lh; % 水平梯度Lh
- Fv = Lv; % 垂直梯度Lv
- % 融合的坐标位置
- w = 57;
- h = 16;
- LX = 123;
- LY = 125;
- GX = 89;
- GY = 101;
- % 贴图融合
- X(LY:LY+h,LX:LX+w,:) = girl(GY:GY+h,GX:GX+w,:);
- Fh(LY:LY+h,LX:LX+w,:) = Gh(GY:GY+h,GX:GX+w,:);
- Fv(LY:LY+h,LX:LX+w,:) = Gv(GY:GY+h,GX:GX+w,:);
- figure(1)
- subplot(231),imshow(uint8(lena),[]);xlabel('lena');
- subplot(232),imshow(uint8(girl),[]);xlabel('girl');
- subplot(233),imshow(uint8(X),[]);xlabel('X');
- subplot(234),imshow(im2uint8(Fh),[]);xlabel('Fh');
- subplot(235),imshow(im2uint8(Fv),[]);xlabel('Fv');
- % mask
- msk = zeros(size(X));
- msk(LY:LY+h,LX:LX+w,:) = 1;
- subplot(236),imshow(msk,[]);xlabel('msk');
- %%
- figure(2)
- tic;
- Y = PoissonJacobi( X, Fh, Fv, msk );
- subplot(121),imshow(uint8(Y),[]);xlabel('PoissonJacobi');
- toc
- tic;
- Y = PoissonGaussSeidel( X, Fh, Fv, msk );
- toc
- subplot(122),imshow(uint8(Y),[]);xlabel('PoissonGaussSeidel');
复制代码 梯度计算:- function [Fh Fv] = imgrad(X)
- Kh = [ 0,-1, 1 ];
- Kv = [ 0;-1; 1 ];
- Fh = imfilter(X,Kh,'replicate');
- Fv = imfilter(X,Kv,'replicate');
复制代码 Poisson Image Reconstruction by Jacobi Algorithm:
- function dst = PoissonJacobi(src, Fh, Fv, msk, itr, th, verbose)
- if( nargin < 5 )
- itr = 1024;
- end
- if( nargin < 6 )
- th = 1E-3;
- end
- if( nargin < 7 )
- verbose = false;
- end
- K=[0,1,0;1,0,1;0,1,0];
- p = ( msk > 0 );
- lap = grad2lap(Fh,Fv);
- df0 = 1E32;
- dst = src;
- dst0 = dst;
- for i = 1:itr
- lpf = imfilter(dst,K,'replicate');
- dst(p) = (lap(p) + lpf(p))/4;
-
- dif = abs(dst-dst0);
- df = max(dif(:));
-
- if( verbose )
- fprintf('%d %g %g\n',i, df, (df0 - df)/df0);
- end
-
- if( (df0 - df)/df0 < th )
- break;
- end
- dst0 = dst;
- df0 = df;
- end
- function lap = grad2lap(Fh, Fv)
- lap = circshift(Fh,[0,1]) + circshift(Fv,[1,0]) - Fh - Fv;
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|